Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
jong

Rounding issue in shopping cart

Question

I can't seem to get rounding correct in the cart, very frustrating. As you can see in my screen shot my first line item should = $81.54 ($27.18 x 3) and then the 2 lines together should = $99.53. I can't and do not want to round in this way. The round should not go past 2 decimal places. This would be not different than buying clothing in a brick-and-mortar retail store, they would not round in this way. I have tried 4 decimal places in preferences-->General as well as every option under 'Round mode.' I have also tried 'Round on each item' and 'Round on each line'. 0_1531856792572_shopping cart rounding issue.PNG 0_1531856893547_current setting for rounding.PNG

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Admin note: it looks like you tried to post three times, landing in the moderation queue each time. I'll remove the other two postings. If one of them has something which is missing here, please add it here as well.

Share this post


Link to post
Share on other sites
  • 0

27.18 x 3 = 81.54 81.54 + 17.98 = 99.52

Looks like rounding is right, just the total of the first line displays one cent too high. It displays $81.55, while it calculates with $81.54.

I've recorded a Github issue to not forget this: https://github.com/thirtybees/thirtybees/issues/553

Share this post


Link to post
Share on other sites
  • 0

This is caused by the CartCore class' getProducts. There is a switch-case over Configuration::get('PS_ROUND_TYPE') which in the default case calls the Tools::ps_round function. The second parameter is _TBPRICEDATABASEPRECISION_ which is in the config set to 6 on default installation. It should use _PSPRICEDISPLAYPRECISION_ or _PSPRICECOMPUTE_PRECISION_ which are both set from (int) Configuration::get('PS_PRICE_DISPLAY_PRECISION').

Until there is a fix, you could use an override for the CartCore class which puts _PSPRICECOMPUTEPRECISION_ instead of _TBPRICEDATABASEPRECISION_ in that spot. Not pretty, but at least it'll work.

Share this post


Link to post
Share on other sites
  • 0

I just modified /config/settings.inc and add this line at the bottom for a quick fix :

define('TBPRICEDATABASEPRECISION_','2');

2 decimals is what i needed, that fixed a lot of problems on cart amounts.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×