Post by skip » Thu Oct 12, 2017 3:47 am

Hi,
I got product with price without tax 0,90
my tax is 25% so it show 1,13 with tax on product page (image 1)

If I set 100 pieces in cart, on cart page Total with tax is 112,50 !!! (image 2) (It should be 1,13*100=113,00)

http://www.opencart-web.xyz/3020/index. ... duct_id=47
This is default opencart without any extenzions!
I supposed problem is in rounded numbers or something like this, how can I fix this problem ? My opencart version is 3020 but it is same on opencart 20x.

Attachments

round2.jpg

image 2 - round2.jpg (163.2 KiB) Viewed 3594 times

round1.jpg

image 1 - round1.jpg (84.16 KiB) Viewed 3594 times


Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by yodapt » Thu Oct 12, 2017 4:18 am

Actually, 25% of 0,90 is 0,225, which totals 1,125. I'm not sure what you think to be the solution, to round the value down instead of up?

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by skip » Thu Oct 12, 2017 4:28 am

yodapt wrote:
Thu Oct 12, 2017 4:18 am
Actually, 25% of 0,90 is 0,225, which totals 1,125. I'm not sure what you think to be the solution, to round the value down instead of up?
As you see something is not wright, because price 1,13*100 pieces is 113,00 in total But in cart show total 112,50 ? and customer is confused
On product page 0,225 is rounded to 0,23 so 0,90+0,23= 1,13
but on cart page is problem because 25% of 90 is 22,50 so system havent got nothing to round

Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by yodapt » Thu Oct 12, 2017 5:08 am

That is just how it is. The values are round to the second decimal, not the first, so 1,55 doesnt become 1,60, but 1,555 becomes 1,56. The best you can do, if you dont want your customers confused over a cent, is to round down the total, so that 1,555 becomes 1,55 instead of 1,56

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by skip » Thu Oct 12, 2017 9:14 am

yodapt wrote:
Thu Oct 12, 2017 5:08 am
That is just how it is. The values are round to the second decimal, not the first, so 1,55 doesnt become 1,60, but 1,555 becomes 1,56. The best you can do, if you dont want your customers confused over a cent, is to round down the total, so that 1,555 becomes 1,55 instead of 1,56
Hm dont know what i get with such solution, and what to change in code or settings to get this ? Thanks

Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by IP_CAM » Thu Oct 12, 2017 11:43 am


My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by arnisraido » Fri Oct 13, 2017 7:44 am

UPDATED! 2017-10-18 with //CHANGE 3

Hi!

Check out this solution: https://github.com/copona/copona/commit ... t-24944535

In file:

Code: Select all

 system\library\cart\tax.php

Code: Select all

// CHANGE 1:
// find line (~line 74):
return $value + $amount;
// replace with
return round($value + $amount, 2);


// CHANGE 2:
// find line (~line 122)
    'amount'      => $amount
// replace with:
    'amount'      => round($amount, 2)
In file:

Code: Select all

system/library/cart/cart.php

Code: Select all

// CHANGE 3:
// find lines (~line 275)
    'price'           => ($price + $option_price),
    'total'           => ($price + $option_price) * $cart['quantity'],
// replace with:
    'price'           => round($price + $option_price, 2),
    'total'           => round($price + $option_price, 2) * $cart['quantity'],



P.S. It has been already discussed here (without a solution). Hope we can fix this together.
Here https://github.com/opencart/opencart/issues/5657
And even here ... https://www.opencart.com/forum/viewtopi ... 19&t=50997
And probably, this one too: https://github.com/opencart/opencart/issues/1990
Last edited by arnisraido on Wed Oct 18, 2017 7:43 am, edited 2 times in total.

Newbie

Posts

Joined
Mon Aug 27, 2012 11:24 pm

Post by skip » Fri Oct 13, 2017 8:32 am

@arnisraido Hi, I can confirm that your modificaton on tax.php made total price corect, but bottom Total , subtotal and tax is not correct, also Total price on top cart button is not corect. Please see image in attachement
Thank You

Attachments

round3.jpg

total - round3.jpg (169.76 KiB) Viewed 3494 times


Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by arnisraido » Fri Oct 13, 2017 5:24 pm

That's great!

Ok, I think, in Copona we use little bit different calculations and my cart was calculating correctly, but I will check.
For Opencart - I have updated the answer with // CHANGE 2:, so - try that one together with previous fix.

Post a feedback.

Newbie

Posts

Joined
Mon Aug 27, 2012 11:24 pm

Post by skip » Sat Oct 14, 2017 3:54 am

Still same for me after change 2

Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by yodapt » Sat Oct 14, 2017 5:34 am

Are you clearing cache after doing those modifications?

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by skip » Sat Oct 14, 2017 10:33 am

yes, I wass refresh modificaton button for extenzion and refresh theme and SASS cache

Active Member

Posts

Joined
Mon May 09, 2011 9:57 pm

Post by arnisraido » Sat Oct 14, 2017 8:55 pm

Ok, please, pm. I would be happy to solve this.

Newbie

Posts

Joined
Mon Aug 27, 2012 11:24 pm

Post by arnisraido » Wed Oct 18, 2017 7:40 am

Additional rounding added. Please, give it a try: https://github.com/copona/copona/commit ... 2bee9e3d04

Full discussion about this also is going on here: https://github.com/copona/copona/commit ... 4a50637b2b

Newbie

Posts

Joined
Mon Aug 27, 2012 11:24 pm

Post by sh0kri2 » Sun Oct 06, 2019 6:28 pm

Is there any solution ?

Newbie

Posts

Joined
Sun Oct 06, 2019 3:07 pm
Who is online

Users browsing this forum: Baidu [Spider] and 102 guests