Disable rounding of decimal places in coupons add-on

I’m trying to apply a discount using the coupons add-on, but I’m struggling to get it to work correctly.

Before discount, the item price is £65.00 with 20% tax applied, making the total price before £78.00. My client wants to apply a per-item discount code for £15 off before tax. I’d initially applied a fixed amount discount of £15, but this didn’t factor in tax, so I increased this to £18. Works fine for a single item being purchased, but it’s a flat rate of £18 discount, regardless of how many items are ordered.

The coupons add-on doesn’t seem to be sophisticated enough to apply a “fixed rate per item” discount, so I’m having to use a percentage-based discount instead. I’ve figured out that the discount rate I need to apply is 23.07692.

But…

The field in the admin area of the plugin seems to round this automatically to 23.08 - which is a problem because it distorts the amount of discount being applied by a few pennies.

I either need to find a better way of applying the discount, which doesn’t seem possible. Or I need a way of disabling the in-built rounding of decimal places, so that it lets me enter exactly the percentage rate I need enter… instead of rounding it to two decimal places, as if it were a currency amount.

Any idea how I get around this problem??

Thank you!

Hi @timkeay,

Dario from Gravity Wiz :man_mage:here, we have a free snippet that lets you Round by increments:

https://gravitywiz.com/rounding-increments-gravity-forms/

From what I understand, this should work for your use case.

If you want to apply discounts with a Discount field instead of Coupons, you can try our Gravity Forms eCommerce Fields Perk that adds a Discount field to add Fixed or % discounts.

I hope this helps!

Best,

1 Like

Hi @dario

Thanks for the reply - very helpful.

I’m not sure that the “round by increments” solution will work by itself. I need the percentage entered to have no rounding whatsoever, whereas that option seems to allow a range of possibilities for rounding the field… except to have zero rounding. Is there any option to disable it entirely?

Applying the discount with a discount field, might be possible… but I’d probably need two fields: one for entering the discount code (conditionally visible when a certain option has been selected from a select/dropdown field - the discount needs to apply to only one product/option), and then the hidden discount field (the one that applies the price reduction)… which is conditionally enabled/shown when the specific code is entered into the field.

I can see how that could possibly be a workaround, but then would the customer need submit the form before the discount was applied? Is there any way of applying the discount visually before submitting the form, like you get with the coupon add-on?

If there was just a way to disable the auto-rounding in the admin, I wouldn’t need to be trying to figure out such a convoluted workaround!

It’s like the auto-rounding has been applied to the field, so that it rounds to two decimal places for currency purposes. That part makes sense. But then an oversight has been made when that same field is given a percentage - it tries to apply the same rounding to the percentage, when it’s entirely unnecessary to do so.

Hi Tim,

The Discount field will apply the discount before form submission and it is visible on the front end.

Best,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.