gform_order_summary

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

  • $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 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 = '
            <tr>
                <td>&nbsp;</td>
                <td>My Custom Option</td>
                <td>$10.00</td>
            </tr>';
    } else {
        $row = '
            <tr>
                <td>&nbsp;</td>
                <td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:right; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">My Custom Option</strong></td>
                <td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">$10.00</strong></td>
            </tr>';
    }

    return str_replace( '<tfoot>', '<tfoot>' . $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 should be placed 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