Using Gravity Forms ‘gform_order_summary’ PHP filter

The gform_order_summary filter in Gravity Forms allows you to modify the markup of the order summary, which appears on the Entry Detail, the {all_fields} merge tag, and the {pricing_fields} merge tag.

Usage

To use the filter for all forms and fields:

add_filter('gform_order_summary', 'your_function_name', 10, 5);

To limit the scope of the filter to a single form, append the form ID to the hook name:

add_filter('gform_order_summary_6', 'your_function_name', 10, 5);

Parameters

  • $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 for the markup. Accepted values are ‘html’ or ‘text’.

More information

See Gravity Forms Docs: gform_order_summary

Examples

Add a custom row to the order summary table footer based on the location the filter is called. Use GFCommon::is_entry_detail() to check if you are on the Entry Detail view. If not, assume the generated markup is for one of the merge tags.

add_filter('gform_order_summary', function($markup) {
    if (GFCommon::is_entry_detail()) {
        $row = '...'; // HTML for Entry Detail view
    } else {
        $row = '...'; // HTML for merge tags view
    }
    return str_replace('<tfoot>', '<tfoot>' . $row, $markup);
});

Change Background Color for the ‘Order’ Row

Change the background color for the ‘Order’ row in the order summary. Replace ‘FF0000’ with any hexadecimal color value.

add_filter('gform_order_summary', function($markup) {
    $markup = str_replace('EAF2FA', 'FF0000', $markup);
    return $markup;
});

Placement

Place the code in the functions.php file of your active theme.

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