-
-
Save samuelaguilera/231d8e4576c9f2190892b980dcc0cb62 to your computer and use it in GitHub Desktop.
Send total without discount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 the payment amount only for subscription feeds. | |
if ( $feed['meta']['transactionType'] != 'subscription' ) { | |
GFCommon::log_debug( __METHOD__ . '(): Not a subscription feed: ' . $feed['meta']['transactionType'] ); | |
return $submission_data; | |
} | |
// 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. | |
$submission_data['payment_amount'] = rgar( $entry, '5' ); | |
GFCommon::log_debug( __METHOD__ . '(): Amount before discount passed to Stripe: ' . $submission_data['payment_amount'] ); | |
return $submission_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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