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.

Custom Total Price Calculation

  1. hpacollect
    Member

    I've got a working credit card form that uses the pricing fields from 1.5RC4 and has the user enter a payment amount, then agree to a fee (it's a fee table, not a percentage), then it adds the fee to the Total field.

    It's functioning perfectly but I just added this code directly to the gravityforms.js file in the middle of the gformCalculateTotalPrice function.

    if(price >= 0.01 && price <= 225)price = price + 10;
    else if(price >= 225.01 && price <= 450)price = price + 20;
    else if(price >= 450.01 && price <= 700)price = price + 30;
    else if(price >= 700.01 && price <= 925)price = price + 40;
    else if(price >= 925.01 && price <= 1500)price = price + 65;
    else if(price >= 1500.01 && price <= 2500)price = price + 105;
    else if(price >= 2500.01 && price <= 3500)price = price + 150;
    else if(price >= 3500.01 && price <= 4500)price = price + 195;
    else if(price >= 4500.01 && price <= 6500)price = price + 275;
    else if(price >= 6500.01 && price <= 8500)price = price + 360;
    else if(price >= 8500.01 && price <= 10000)price = price + 425;

    I know this is a problem when I go to do Gravity updates the file will be overwritten. So I've looked through other threads and documentation that may point how to do this the correct way using filters, hooks, etc. but I couldn't figure out the right way to do this.

    Here is a link to the form, just enter a payment amount and click the "I agree to the fee" checkbox and you will see the total calculation.

    https://hpaglobalrecovery.com/online-payment-form/credit-card-payment

    Can anyone suggest a more proper way of doing this?

    Thanks in advance.

    Posted 13 years ago on Friday February 11, 2011 | Permalink
  2. Hi Hpacollect,

    Here is how I would recommend accomplishing this:

    1 - Create another User Defined field for your Administrative fee.
    2 - Using jQuery, bind a function to the change event of your "Amount of Payment" field.
    3 - Inside this function, use your price table to determine the administrative fee and also using jQuery set this fee as the value of the "Adminstrative Fee" field we created in step one.
    4 - That's it! Gravity Forms will now calculate the total of both fields. If you'd like to hide the Adminstrative field from view, just find the ID of the field and use CSS to "display:none;"

    Posted 13 years ago on Friday February 11, 2011 | Permalink
  3. hpacollect
    Member

    David,

    Thanks for your quick and detailed reply. It makes sense, I'll get working on fixing this.

    Thanks so much!

    Posted 13 years ago on Friday February 11, 2011 | Permalink

This topic has been resolved and has been closed to new replies.