PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

[SOLVED] Item on sale :: Rounding problem

5 replies to this topic
#1
Entcee

    PrestaShop Newbie

  • Members
  • Pip
  • 20 posts
I have an item that is $4.99 but have it on sale at 20% off so the item is $3.99 (actually it is $3.992).

This is not a problem until someone buys 3 of them. When they do, the total should be $11.97 but the cart shows $11.98 (because the total is really $11.976).

Normally this would not be a problem but when the customer is transfered to PayPal's site, the total is displayed as $11.97. This creates a discrepancy between PayPal and Prestashop.

Anyone know what I have to change to get Prestashop to round each item separately (even when it is multiples of the same item) instead of rounding all the same items together?

Thanks in advance

#2
mr_c

    PrestaShop Apprentice

  • Members
  • PipPip
  • 42 posts
I recommend you report it as a bug in the bug tracker (http://www.prestashop.com/bug_tracker/) the presta people will look at it and reply, if it is in fact a bug, they'll try to fix it for the next version.

#3
Entcee

    PrestaShop Newbie

  • Members
  • Pip
  • 20 posts
Thanks, I did note it in the bug tracker.

Since then, I found where to fix it...

classes\Product.php (approx line 1192)

I changed this:
elseif ($reduction_percent AND $reduction_percent > 0)
{
if ($reduction_percent >= 100)
$ret = $product_price;
else
$ret = $product_price * $reduction_percent / 100;
}
return isset($ret) ? $ret : 0;



to this (look at the 6th line):
elseif ($reduction_percent AND $reduction_percent > 0)
{
if ($reduction_percent >= 100)
$ret = $product_price;
else
$ret = round($product_price * $reduction_percent / 100, 2);
}
return isset($ret) ? $ret : 0;


Now it is working like I think it should!

#4
mr_c

    PrestaShop Apprentice

  • Members
  • PipPip
  • 42 posts
great! paste the fix in the comments in the bug reported so they can simply easily fix it and have it fixed in the next version for people who might have the same problem in the future.

#5
gianvi

    PrestaShop Apprentice

  • Members
  • PipPip
  • 189 posts
Just a question :

if i have a price of 599,00 and i apply a 35% discount, i will have 389,35.

Where i have to run on the code to have 389,00 ?

i try to modify the code as described up, but no results.

Tks for your help
Prestashop ver. 1.4.3
Now Presta Website is offline but if you want to check what i do in my life to try to survive .... http://www.gvmshop.com/shop

#6
Hardik

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
you will have to go to tools.php in classes/tools.php

goto the "convertPrice" function

round($price,-1); might help, but you'll have to try it out