1

Is it possible to manually set the currency during the checkout process? Right now Im trying the following (set currency to CAD for Canadian buyers), which seems to break the cart array....

{% if cart.shippingAddress.countryId == '38' %}
  {% set cart = cart|merge({'paymentCurrency': 'CAD'}) %}
{% endif %}
2

According to the documentation, carts are represented by the craft\commerce\elements\Order class. The API documentation is a useful way of finding available methods and properties. In this case, Order::setPaymentCurrency seems to be what you're looking for. So this should work:

{% if cart.shippingAddress.countryId == '38' %}
  {% do cart.setPaymentCurrency('CAD') %}
{% endif %}
3
  • 1
    Amazing. Thanks! Aug 13 at 22:05
  • This seems to be working now just fine (after removing COMMERCE_PAYMENT_CURRENCY in my index file) and setting the paymentCurrency POST variable in my /pay form. BUT -- any way to have the backend reflect the currencies actually charged? It seems to always show the store default on the order screen... Aug 14 at 18:59
  • @DocumentServices Not sure about that, sorry. Maybe post that as a new question!
    – MoritzLost
    Aug 16 at 7:53

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.