1

We have a site-wide sale on with 10% off products. On the category/detail page the commerceCurrency filter appears to round down, but when a customer adds an item to the basket, it's shown correctly as the rounded up price. Just had a complaint that it was 1p more than advertised (can you believe!).

Weirdly it rounds up correctly on my dev machine, which is running Ubuntu Desktop. Both running 18.04 LTS and PHP 7.3 with the same packages installed.

I have dug around the commerce/yii codebase and it's ultimately using the vendor/yiisoft/yii2/i18n/Formatter.php asCurrency() method.

I can write my own macro/filter to correct this, but seems like a bug to me.

e.g. Price £16.95, on Sale, £15.255.

{{ product.defaultVariant.salePrice|commerceCurrency(cart.currency) }}

Results in £15.25, but the value 15.26 is saved to commerce_lineitems and added to the cart.

0

It looks like there is currently a Github issue/feature request for this that is on the Commerce 3.0 milestone: https://github.com/craftcms/commerce/issues/695

|improve this answer|||||
  • Thanks for the update. Will implement some twig code to make sure it displays correctly in the meantime – Ant Cooper Oct 23 '19 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.