[Skip to main content](#vessel-content)

#   How can I set to not round the discounts in the order?

##

- **[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")**
- [![FM Supply's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/60580-fm-supply "View FM Supply's Profile") Topic Author
- [ Offline](/forum/user/60580-fm-supply)

Less More

- Posts: 11
- Thank you received: 0
-
-

3 years 10 months ago [\#347739](#347739) by [FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")  *[How can I set to not round the discounts in the order?](/forum/46-discount-coupon/905580-how-can-i-set-to-not-round-the-discounts-in-the-order#347739 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3.33  Hi support,  I've set Round prices during calculations to &quot;NO&quot; in the backend but even still the discounts are being rounded up. I have a 1% coupon to all products and a 3% discount in the payment method (bank transfer) as an option. How can I set to not round the discounts in the order?")* was created by *[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")*

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.33

Hi support,

I've set Round prices during calculations to "NO" in the backend but even still the discounts are being rounded up.
I have a 1% coupon to all products and a 3% discount in the payment method (bank transfer) as an option.
How can I set to not round the discounts in the order?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi85MDU1ODAtaG93LWNhbi1pLXNldC10by1ub3Qtcm91bmQtdGhlLWRpc2NvdW50cy1pbi10aGUtb3JkZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

3 years 10 months ago [\#347741](#347741) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How can I set to not round the discounts in the order?](/forum/46-discount-coupon/905580-how-can-i-set-to-not-round-the-discounts-in-the-order#347741 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3.33  Hi support,  I've set Round prices during calculations to &quot;NO&quot; in the backend but even still the discounts are being rounded up. I have a 1% coupon to all products and a 3% discount in the payment method (bank transfer) as an option. How can I set to not round the discounts in the order?")*

Hi,

Prices are always rounded. It doesn't make sense to display an amount at 9.999999€ for example.
So HikaShop will round any amount being displayed based on the rounding settings of the currency being used. So if you configure the rounding to be at 2 decimals in your currency, then no matter if the amount displayed is a discount, a tax, a shipping fee, a product price or something else, if the amount is 9.999999... it will be rounded to 10.00€.
The "Round prices during calculations" setting is to choose to round amounts during the calculations and when displaying the amounts, or only when displaying the amounts.
For example, suppose I have a product priced at 10€ with a discount at 33.33333%. The discounted amount would be 3.333333
With the setting activated, this amount would be rounded 3.33. Then, suppose I'm buying a 100 of these products.
That would be a total discount of 3.33 * 100 = 333 for a grand total of 667€.
With that setting turned off, the total discount would be 333.33333 displayed as 333.33 for a grand total of 666.67€
Both modes of calculations are correct. It depends on the rules you set for yourself. For example, PayPal makes its calculations similarly to HikaShop when the setting is activated. Most accounting software make their calculations similarly to HikaShop when the setting is turned off.

So to go back to your question: I'm not sure what you mean. Do you mean that you set a rounding of 0 in your currency but you want discounts to be displayed with a rounding of 2 decimals ? That's not possible. In that case, you want to set the rounding to 2 in the currency and all the amounts will display with a rounding of 2 decimals. But then the question is why you did this in the first place ? Maybe there is another solution to what you were trying to do ? Or maybe you're talking about something totally different and I would need more details to understand your situation and what you're trying to achieve to be able to answer.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi85MDU1ODAtaG93LWNhbi1pLXNldC10by1ub3Qtcm91bmQtdGhlLWRpc2NvdW50cy1pbi10aGUtb3JkZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")**
- [![FM Supply's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/60580-fm-supply "View FM Supply's Profile") Topic Author
- [ Offline](/forum/user/60580-fm-supply)

Less More

- Posts: 11
- Thank you received: 0
-
-

3 years 10 months ago [\#347812](#347812) by [FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")  Replied by *[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")* on topic *[How can I set to not round the discounts in the order?](/forum/46-discount-coupon/905580-how-can-i-set-to-not-round-the-discounts-in-the-order#347812 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3.33  Hi support,  I've set Round prices during calculations to &quot;NO&quot; in the backend but even still the discounts are being rounded up. I have a 1% coupon to all products and a 3% discount in the payment method (bank transfer) as an option. How can I set to not round the discounts in the order?")*

Hi support,

What I meant was that the system is rounding up with the discount.

For instance it should be like this:

total $103.63
Discount (1%) 1.0363 -&gt; -1.03

The system displays like this: -1.04

Is it possible to avoid this? Let me know how, please.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi85MDU1ODAtaG93LWNhbi1pLXNldC10by1ub3Qtcm91bmQtdGhlLWRpc2NvdW50cy1pbi10aGUtb3JkZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

3 years 10 months ago -  3 years 10 months ago [\#347813](#347813) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How can I set to not round the discounts in the order?](/forum/46-discount-coupon/905580-how-can-i-set-to-not-round-the-discounts-in-the-order#347813 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3.33  Hi support,  I've set Round prices during calculations to &quot;NO&quot; in the backend but even still the discounts are being rounded up. I have a 1% coupon to all products and a 3% discount in the payment method (bank transfer) as an option. How can I set to not round the discounts in the order?")*

Hi,

Well, rounding normally works like that:
When you have 0.001, 0.002, 0.003 or 0.004, rounding it to 2 decimals means it would output 0.00.
When you have 0.006, 0.007, 0.008 or 0.009, rounding it to 2 decimals means it would output 0.01.
So it's normal the system displays -1.04 for -1.0363 as that's how rounding normally works. You can read more about rounding numbers here:
[ www.mathsisfun.com/rounding-numbers.html](https://www.mathsisfun.com/rounding-numbers.html)

Now, it is possible to change the way rounding works in PHP:
[ www.php.net/manual/en/function.round.php](https://www.php.net/manual/en/function.round.php)
The round function (which we use in HikaShop) has a third argument you can use to change the mode for 0.005.
If you want to change it, you can change the line:
return round($price, $round);
For example, you could change it to:
return round($price, $round, PHP_ROUND_HALF_DOWN);
in the file administrator/components/com_hikashop/classes/currency.php

But even so, it doesn't handle truncate. So for example, you can't have 1.039, or 1.036 to output 1.03 with that function. So, in your example, it wouldn't change what is displayed. If you want to achieve a truncate instead of a rounding, you would have to add a truncate function like: Code:

function truncate($number, $precision = 2) { $fig = (int) str_pad('1', $precision, '0'); return (floor($number * $fig) / $fig); }

and use that function instead of the round function of PHP there.
However, I don't recommend it. This will affect all calculations, including tax calculations. Also, I think it might not be legally allowed to do that in some countries. So before changing the way the rounding is done, I would recommend you to check with your accountant what they suggest.

Last edit: 3 years 10 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi85MDU1ODAtaG93LWNhbi1pLXNldC10by1ub3Qtcm91bmQtdGhlLWRpc2NvdW50cy1pbi10aGUtb3JkZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.067 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
