Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send total without discount
<?php
// NOTE: THE CODE TO COPY/PASTE STARTS BELOW THIS LINE
/* Change 10 in gform_submission_data_pre_process_payment_10 to your form id number (e.g. gform_submission_data_pre_process_payment_1 form id 1)
or remove the _10 to apply this to all forms */
add_filter( 'gform_submission_data_pre_process_payment_10', 'modify_submission_data', 10, 4 );
function modify_submission_data( $submission_data, $feed, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
// Change 5 in the following line to the id of the field that has the total amount without discount.
// IMPORTANT! It can't be a Total field type, or the snippet will be useless.
$total_field = rgar( $entry, '5' );
GFCommon::log_debug( __METHOD__ . '(): Amount in Total field before discount: ' . $total_field );
$submission_data['payment_amount'] = $total_field;
GFCommon::log_debug( __METHOD__ . '(): Original Total amount passed to Stripe: ' . $submission_data['payment_amount'] );
return $submission_data;
}
@kennys74

This comment has been minimized.

Copy link

kennys74 commented Feb 20, 2018

Hi there. I'm not sure the code above is 100% correct Samuel. I've tested this now on our site: www.register.za.com. If I declare this variable: $total_field = rgar( $entry, '13' ) it equals the new total including the discount. My total field ID is 13. It needs pass the total prior to the discount which on our form is a hidden form field with a name: "gf_total_no_discount_2". How would I get this variable from calling rgar() function?

Many thanks

Ken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment