gpecf_order_summary
Description
Filter the order summary.
Usage
Apply to all forms.
add_filter( 'gpecf_order_summary', 'my_custom_function' );
Apply to a specific form.
add_filter( 'gpecf_order_summary_FORMID', 'my_custom_function' );
Parameters
Examples
Consolidate Discounts
In this example, discounts are consolidated to a single line item in the Order Summary.
<?php
/**
* Gravity Perks // eCommerce Fields // Consolidate Separate Discount Line Items into a Single Discounts Line Item
* https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
*
* Instruction Video: https://www.loom.com/share/8c00449041864d30833d334274947484
*
* Default: https://gwiz.io/2IiPALf
* w/ Snippet: https://gwiz.io/2Itfyfo
*/
// Update "123" to your form ID - or - remove "_123" to apply to all forms.
add_filter( 'gpecf_order_summary_123', function( $summary ) {
if ( empty( $summary['discounts'] ) ) {
return $summary;
}
$consolidated_discount = $summary['discounts'][0];
$consolidated_discount['name'] = 'Discounts';
$consolidated_discount['price'] = 0;
foreach ( $summary['discounts'] as $discount ) {
$consolidated_discount['price'] += $discount['price'];
}
$summary['discounts'] = array( $consolidated_discount );
return $summary;
} );
Add Custom Total
In this example, we add a custom total to the Order Summary.
<?php
/**
* Gravity Perks // GP eCommerce Fields // Add Custom Total to Order Summary
* https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
*/
// Update "123" with your form ID.
add_filter( 'gpecf_order_summary_123', function( $order_summary ) {
$order_summary['total'] = array_merge( array(
array(
'name' => 'Recurring Total',
'price' => '$400',
'quantity' => 1,
'class' => 'total',
),
), $order_summary['total'] );
return $order_summary;
} );
Since
This filter is available since Gravity Forms eCommerce Fields 1.0.15.