PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Add surcharge to the Total on form.

  1. Hi

    Paypal has fees when you want to sell thru them. Can someone please help me put a 2.5% surcharge on the total so that the buyers will pay for the fees?

    Please help me, I need to do this urgently.

    Posted 13 years ago on Thursday March 24, 2011 | Permalink
  2. Hi Ruby,

    Here is a method you can use to accomplish this:

    1. Add this code to your theme's functions.php file: http://pastie.org/1722092
    2. On the first line of the code, update the '45' to the ID of your form
    3. Go to your form admin and add a new product field to your form. Select "User Defined Price"as the field type and specify 'surcharge' as the CSS class. http://grab.by/9I23 http://grab.by/9I24
    4. Make sure your form has a total field.
    5. That's it! It should look something like this when submitting to PayPal: http://grab.by/9I2e
    Posted 13 years ago on Sunday March 27, 2011 | Permalink
  3. Thank you Thank you Thank you Thank you.

    Just two more questions, Is it possible to make it so users cannot type in the surcharge field. I tried 200 and it was added to the Total with the surcharge counting it. Or can I make it hidden? (as long as it appears on the Paypal page)

    Also in the address field is it possible to change "City" to "Suburb"?

    Thank you so much for your help!

    Posted 13 years ago on Sunday March 27, 2011 | Permalink
  4. Currently the Product field does not support a Hidden field type, but it's a good idea and we'll look at adding that in an upcoming release (possibly the next one). Until then, you can hide the surcharge field by editing it, going to the Advanced tab and in the Custom CSS Class field enter: gform_hidden

    The "City" sub-label of the Address Field can be changed via custom code you would add to your themes functions.php where any custom code would typically go. Documentation for the filter to change the "City" label can be found here:

    http://www.gravityhelp.com/documentation/page/Gform_address_city

    Posted 13 years ago on Monday March 28, 2011 | Permalink
  5. Hi Ruby,

    Give the 'gform_hidden' class a try but if you find that the value is not being passed to PayPal, try replacing the old code with this updated code:

    http://pastie.org/1726665

    Posted 13 years ago on Monday March 28, 2011 | Permalink
  6. Thanks David. Works beautifully.

    When I try to change City into Suburb, I can't access my sites admin, it says there's an error on the line which has <?php

    Posted 13 years ago on Tuesday March 29, 2011 | Permalink
  7. The updated code doesn't let me log in to my wp admin. A blank page just comes. I have done what Carl said and that works.

    Posted 13 years ago on Tuesday March 29, 2011 | Permalink
  8. The code above has been updated to prevent the surcharge from being recalculated inaccurately when validation errors force the user to submit the form again: http://pastie.org/1912751

    Posted 13 years ago on Monday May 16, 2011 | Permalink
  9. The first solution is great and does almost exactly what I need but is there a way to have it add/subtract the amount only if the total reaches a certain amount? I appreciate your help!

    Here is the link to my form: http://1106design.com/newsite/services/

    Posted 12 years ago on Thursday March 15, 2012 | Permalink
  10. Where do I add this code, as I have the exact same problem, and I want it to do this on all of the forms I create for my website, so how do I do that?

    Posted 12 years ago on Monday March 26, 2012 | Permalink