Description
The gform_order_summary filter in Gravity Forms filters the markup of the order summary which appears on the Entry Detail, the {all_fields} merge tag and the {pricing_fields} merge tag.
Usage
The base filter which would run for all forms and fields can be used like so:
add_filter( 'gform_order_summary', 'your_function_name', 10, 5 );
You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_order_summary_6', 'your_function_name', 10, 5 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$markup | string | The order summary markup. |
$form | Form Object | The current form. |
$entry | Entry Object | The current entry. |
$order_summary | array | An array containing the products, options and shipping for the current entry. |
$format | string | The format with which the markup should be formatted. Accepted values are ‘html’ or ‘text’. |
Examples
Add a Row to the Order Summary Table Footer
Note that the markup differs slightly depending on the location where the filter is called. When generated for the {all_fields} and {pricing_fields} merge tags, inline styles are included. When called from the Entry Detail view, inline styles are not included.
We recommend using GFCommon::is_entry_detail() to check if you are on the Entry Detail view. Otherwise, assume the generated markup is for one of the merge tags.
add_filter( 'gform_order_summary', function( $markup ) {
if ( GFCommon::is_entry_detail() ) {
$row = '
My Custom Option
$10.00
';
} else {
$row = '
My Custom Option
$10.00
';
}
return str_replace( '', '' . $row, $markup );
} );
Change background color for the ‘Order’ row
The following example will simply change the background color for the ‘Order’ row from default color to red. Change FF0000 to any hexadecimal color value of your choice.
add_filter( 'gform_order_summary', function( $markup ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
// Change background color for the 'Order' row to FF0000 (red).
$markup = str_replace( 'EAF2FA', 'FF0000', $markup );
return $markup;
} );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
Added in Gravity Forms 2.1.2.5.
Source Code
This filter is located in:
- GFCommon::get_submitted_pricing_fields() in common.php
- GFEntryDetail::lead_detail_grid() in entry_detail.php