PayPal Standard Add-On form total incorrect when using conditional logic

I have a form that creates a registration within the system and then sends the user to PayPal via the PayPal Standard Add-On functionality in order to collect payment. There is a single product with a fixed quantity (of one) and fixed price ($20). This all works as expected.

I’ve since been instructed to add a “Promo/Discount” code to the form that would add a discount of $10 for anyone with the appropriate discount code.

I’ve created a new product field on the form called “Discount” and added a single-line text field called “Discount Code”. I’ve enabled conditional formatting on the “Discount” field such that it is only enabled in the event that the “Discount Code” field’s value matches the valid code. On the frontend, the form does exactly what I expect. The “Discount” product’s field appears when the “Discount Code” value matches and the form total adjusts from $20 to $10.

The problem is that the PayPal redirection querystring that is being generated by the PayPal Standard Add-On doesn’t appear to take the conditional formatting into account and so the total that it sends along to PayPal is the full $20 regardless of the addition or omission of the “Discount” product. Enabling logging and checking the Add-On’s debug output confirms that the “Discount” product is never added.

** NOTE: I do realize that there is an Elite “Coupon” Add-On, but we only have a Pro license and I haven’t been given any budget for this functionality and want to explore all current options before going back with a “You have to pay for that functionality” response. **

Has anyone dealt with PayPal feeds and conditional logic not playing nicely together? Perhaps there is a better way to conditionally modify the price value?

Cheers!

How about if you had two product fields:

Standard Price $20
Discounted Price $10

Prior to that, in the form, offer a single line text field called “Discount Code”. If the Discount Code is correct, use conditional logic in the form to show one Product field or the other. They will look the same, except for the price. If you send the form total to PayPal, only the one visible product will be included in the form total and that will be correct.

One downside to this is that the conditional logic value (the discount code) will be in the source of the page in case anyone inspects, or take a little bit deeper look.

Chris’s answer is definitely a great way to do this if you’re not looking to spend any money. If you’re willing to part with a few dollars to save a some time now and configuration overhead later, check out my Gravity Forms eCommerce Fields plugin.

It supports a handy Discount field which will play nice with PayPal and looks :ok_hand:. Happy to answer any questions you might have. :slightly_smiling_face:

1 Like

@chrishajer,

Thanks for the response. I have tried using a “replacement” method via the conditional formatting instead of adding a negative “discount” amount to the existing registration fee, but there is a payment amount error that appears in the logs and it will not forward users to PayPal upon submission, it goes directly to the success messaging.

To reiterate, here is the current setup:

  • Single-Line Text Field “Promo Code”
  • Product Field “Registration Fee”, $20 with a fixed quantity of one, conditional logic telling the form to display it only if the “Promo Code” field’s value does NOT equal “testpromo”
  • Product Field “Discounted Registration Fee”, $10 with a fixed quantity of one, conditional logic telling the form to display it only if the “Promo Code” field’s value equals “testpromo”
  • PayPal feed that sends along consumer information and the “Form Total” as the price

The log for the PayPal Standard Add-On for this submission looks as follows:
2020-08-08 4:09:19.428642 - DEBUG --> GFPaymentAddOn::validation(): Aborting. Payment amount not valid for processing.
2020-08-08 4:09:19.440512 - DEBUG --> GFFeedAddOn::maybe_process_feed(): Checking for feeds to process for entry #26 for gravityformspaypal.
2020-08-08 4:09:19.441365 - DEBUG --> GFFeedAddOn::maybe_process_feed(): Starting to process feed (#2 - PayPal Feed 1) for entry #26 for gravityformspaypal
2020-08-08 4:09:19.441421 - DEBUG --> GFFeedAddOn::maybe_process_feed(): Marking entry #26 as fulfilled for gravityformspaypal

That is good information. I recommend adding some additional logging to the form, since you already have logging enabled. Add this to your theme functions.php file:

add_filter( 'gform_paypal_query', 'log_the_paypal_query', 10, 3 );
function log_the_paypal_query( $query_string, $form, $entry ) {
	GFCommon::log_debug( __METHOD__ . '(): This is the query string => ' . print_r( $query_string, true ) );
	GFCommon::log_debug( __METHOD__ . '(): This is the entry => ' . print_r( $entry, true ) );
	return $query_string;
}

That will log the query string and the entry and we can see exactly what is being sent and if there is a way to change that. This information will be logged to the Gravity Forms Core log after you test the form.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.