Prestashop: getPackageShippingCost bad rounding

Created on 27 Aug 2019  Â·  4Comments  Â·  Source: PrestaShop/PrestaShop

Describe the bug
In the function getPackageShippingCost, the result value is always rounded to 2 decimals, This leads to errors in the cart totals calculations, in the invoices and in the emails templates.

The actual code is:

$shipping_cost = (float) Tools::ps_round((float) $shipping_cost, 2);

It should be:

$shipping_cost = (float) Tools::ps_round((float) $shipping_cost, 6);

To Reproduce
Simply check the result of the totals calulations in shopping cart.

Additional information
PrestaShop version: all
PHP version: 7.2

Bug FO No change required Shopping carts FO Taxes and Prices

Most helpful comment

The problem is with the shipping cost, not the product price.

All 4 comments

Hi @stefanovita,

Thanks for your report.
I tried with PS1.7.6.1 with a default product.
In the BO
image

In the shopping cart FO is well calculated
image

PS: It's planned to remove the number of decimal parameters in Shop parameters > General.
image

You can follow this ticket: https://github.com/PrestaShop/PrestaShop/issues/12223
And it's also planned to add this feature in CLDR part 2: #11660

Thanks to check & feedback.

The problem is with the shipping cost, not the product price.

@stefanovita, sorry, it is my bad.
I tried with this price shipping => 7.145000, in the FO => It will display €7.15
I tried with this price shipping => 7.1447, in the FO => It will display €7.14
I attached a screen record
https://drive.google.com/file/d/16yK0ZiNZQfjrr2wP-bJx-9u5AkV2Bdxe/view
Thanks to check & feedback.

Hi @stefanovita,

Since we had no news from you for more than 30 days, I'll close this ticket. Feel free to open another one if you can give specific details.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings