1

Within Settings, the cart currency is set to Euros. But when I use:

{{ product.defaultVariant.price | currency(cart.currency) }}

The output is:

¤150.49

Anyone encountered this before?

5
  • 1
    Is this perhaps related to the font you are using to show the currency in front-end templates? Have you tried using different fonts to see if the problem persists? Commented Aug 8, 2016 at 18:08
  • No, I don't think so. I'm just using Arial and it's in the page source. Commented Aug 9, 2016 at 9:40
  • What does cart.currency return? Looking through the code, the Twig currency filter ultimately uses Yii's CNumberFormatter class. This uses the symbol you are seeing as a default placeholder for the currency symbol if one cannot be determined from the value of the $currency parameter passed to it. See here: yiiframework.com/doc/api/1.1/CNumberFormatter#format-detail This would indicate that the value of cart.currency is not as expected. How is this being set? Commented Aug 9, 2016 at 10:07
  • Good point. That was the problem. I'd not included {% set cart = craft.commerce.cart %} anywhere so the cart was missing. Do you want to add that as an answer and I'll mark it as accepted? Commented Aug 9, 2016 at 10:41
  • Great! I've added is as an answer now. Commented Aug 9, 2016 at 10:46

2 Answers 2

2

What does cart.currency return?

The Twig currency filter ultimately uses Yii's CNumberFormatter class. This uses the symbol you are seeing as a default placeholder for the currency symbol if one cannot be determined from the value of the $currency parameter passed to it. This would indicate that the value of cart.currency is not as expected. You'll need to make sure that the cart variable is being set correctly in your template, then this should work.

0

As Steve mentions, most likely this is because the font you are using on the front-end of your site doesn't know how to display the € symbol.

I just tested on a fresh Craft/Commerce install on OSX/Chrome and the default Commerce templates display € as expected.

2
  • See reply to Steve above. Commented Aug 9, 2016 at 9:40
  • Once again, I bow to @SteveRowling's superior knowledge.
    – Brad Bell
    Commented Aug 9, 2016 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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