bookmark_bordergform_submission_data_pre_process_payment

Description

This filter can be used to modify the Submission Data before it’s used during feed processing by a payment add-on based on the Add-on Framework.

Usage

The base filter which would run for all forms with a payment add-on feed would be used like so:

add_filter( 'gform_submission_data_pre_process_payment', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (format: gform_submission_data_pre_process_payment_FORMID)

add_filter( 'gform_submission_data_pre_process_payment_10', 'your_function_name', 10, 4 );

Parameters

  • $submission_data Submission Data

    Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values and any discounts from coupons.

  • $feed Feed Object

    The feed currently being processed.

  • $form

    The Form currently being processed.

  • $entry Entry Object

    The Entry currently being processed.

Examples

1. Change the payment amount

This example shows how you can override the payment_amount for form 10 with the value from field 5.

add_filter( 'gform_submission_data_pre_process_payment_10', 'modify_submission_data', 10, 4 );
function modify_submission_data( $submission_data, $feed, $form, $entry ) {
    $submission_data['payment_amount'] = rgar( $entry, '5' );

    return $submission_data;
}

2. Set the number of trial days

This example shows how you can override the trial property (i.e. the number of trial days) for form 5.

add_filter( 'gform_submission_data_pre_process_payment_5', 'modify_submission_data', 10, 4 );
function modify_submission_data( $submission_data, $feed, $form, $entry ) {
    $submission_data['trial'] = 15;

    return $submission_data;
}

3. Set the Authorize.net line item taxable status

This example shows how you can override the default taxable status of Y to N for the line items of form 3. This is supported as of Authorize.net version 2.2.1.

add_filter( 'gform_submission_data_pre_process_payment_3', 'override_line_item_tabaxable', 10, 4 );
function override_line_item_tabaxable( $submission_data, $feed, $form, $entry ) {
	foreach ( $submission_data['line_items'] as &$line_item ) {
		$line_item['taxable'] = 'N';
	}

	return $submission_data;
}

Placement

This code should be placed in the functions.php file of your active theme

Source Code

gf_apply_filters( 'gform_submission_data_pre_process_payment', $form['id'], $submission_data, $feed, $form, $entry );

This filter is located in GFPaymentAddOn::get_submission_data() in includes/addon/class-gf-payment-addon.php

Since

This filter was added in Gravity Forms 1.9.12.8.