GravityExport field: ProductField
Gravity Formsโ default export isnโt always consistent or useful for Excel. Thatโs why weโve created this class. It is responsible for these fields: singleproduct ย and calculation . Both of them are products, and the export returns a quantity and a price. And when you export with separated fields, thereโs no problem. But when you want all that info in one field, itโs kind of mushed together. So this field tries to offer you a nice default, as well as a filter to overwrite it.
Filters #
gfexcel_field_*type*_prepend_{form_id}_{input_id}ย In this filter, the*type*ย part should be replace by eithersingleproductย orcalculation. It gives you the ability to prepend the value of the individual data, likeQtyย andPrice.
Example #
/**
* Filters the prepend label for a single product field input during export.
*
* This hook allows you to customize the text that appears before the value
* of a specific product input (e.g., quantity, price, or option) in a GravityExport export.
*
* @since 1.0.0
*
* @param string $prepend The text prepended to the product input label. Defaults to "Qty: " for quantity inputs.
* @param int $input_id The ID of the input within the field (not the field ID itself).
*
* @return string The modified prepend text.
*/
add_filter(
'gfexcel_field_singleproduct_prepend',
function ( $prepend, $input_id ) {
// $input_id is the ID of the input within the field, not the field ID itself.
if ( (int) $input_id === 3 ) { // 3 happens to be the key for Quantity ("Qty: " by default).
$prepend = 'Amount: ';
}
return $prepend;
},
10,
2
);