0

Is there a way for users/customers to set a custom/preferred currency that would be applied to any future carts (assuming more than one currency was available)?

Was looking at whether could do this via a plugin using the User::EVENT_AFTER_LOGIN event to fetch and modify/create a cart object, eg something like the following where $curr is user defined currency (iso):

Event::on(
  User::class, 
  User::EVENT_AFTER_LOGIN, 
  function (Event $e) {
    $order = Commerce::getInstance()->getCarts()->getCart(true);
    $order->setPaymentCurrency( $curr );
  }

If I try and dump the order object it shows the currency value has been updated. However, if I access the cart in subsequent templates the payment currency has returned to the default/primary currency.

Any thoughts on updating a cart currency via a plugin eg against a saved/stored value (eg via User Fields)

Your Answer

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

Browse other questions tagged or ask your own question.