I had a form that at one time was working perfectly. It seems like randomly it decided to stop working. So it seems.
I wrote some custom code to check a text field for a discount code entered and then add a product with a negative amount and pass it through gform_product_info. I can no longer get gform_product_total to dynamically update my front end total (but that's a different problem) and while testing my form to see if the backend stuff still worked, I got this error from paypal:
"The link you have used to enter the PayPal system contains an incorrectly formatted item amount."
I've been hunting around for a couple of hours now and can't figure out what paypal has an issue with. I thought it might suddenly have a problem with negative amounts, but according to https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing the item price can be positive or negative, but not zero. When no discount code is used paypal brings up a total summary just fine.
The relevant products part of the URL being sent to paypal is:
"item_name_1=Austin%2C+TX+-+August+11-18&amount_1=320&quantity_1=1&item_name_2=Discount+MLD2012&amount_2=-30&quantity_2=1"
My code for sending the discount info to paypal is:
function update_product_info($product_info, $form, $entry) {
$code = $entry[88];
if($code == 'MLD2012' || $code == 'mld2012'){
$total = get_total($product_info);
$discount = -30;
$product_info['products']['tax'] = array(
'name' => 'Discount MLD2012', // name that will appear in PayPal and pricing summary tables
'price' => $discount, // amount of total discount
'quantity' => 1
);
}
return $product_info;
}
add_filter('gform_product_info_9', 'update_product_info', 10, 3);
You can see the form live at: http://www.youthunlimited.org/form-test/ (if you feel like checking the script I'm loading with the gform_pre_render filter and seeing if you can tell why it won't change my front end total, then that's a bonus)
in summary, paypal is annoying. hopefully you guys can see quickly what may be going wrong. I always appreciate the quality support here.
Thanks!
-Jarrod