Currency switching in the cart is not working

Created on 21 December 2023, 12 months ago
Updated 3 June 2024, 7 months ago

Hello,
I have noticed that the Currency Resolver is not working properly on versions 10.1.x and 10.2.x.

If you install multiple currencies and languages (although this might not be a condition), and set, for example, the default currency to CZK, then install the latest Drupal Commerce and the latest Currency_Resolver (set up some conversion mechanism, I've tried all possible combinations), create a product, add a variant with an amount in CZK currency, and add the product to the cart. If you change the currency in the Currency switcher to another currency, like EUR, the cart updates correctly to EUR. But when you switch back to the original CZK currency, it does not switch back properly; only the "Subtotal" switches back to CZK, but the rest remains in EUR as before.

I don't think the problem is in the settings or theme, as I tried the default theme and it's still the same. I suspect there is an issue with handling product variations and the injection of currency policy for these variants.

I even tried a field for CZK currency, but it's the same.

πŸ› Bug report
Status

Active

Version

1.70

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @marekdvorak
  • I faced a similar problem, but in my case, only the value of "Total" was changed, not "Subtotal". The attached patch fixed it

  • πŸ‡¬πŸ‡§United Kingdom londova

    I have similar problem as well

  • πŸ‡©πŸ‡ͺGermany marcusx

    I have the same problem and this patch fixes a lto of issues but the order total amount is not refreshed imideately for some reason. I have to trigger another refresh by stepping one screen forward in the checkout process.

    I could avoid this by adding an

    $order->save()
    

    after the refresh.

  • πŸ‡ΊπŸ‡¦Ukraine dimon4ikzp

    #4 works great for me, but I have to comment

    $order->save()
    

    to avoid WSOD with error:

    Drupal\Core\Entity\EntityStorageException: The provided prices have mismatched currencies:

Production build 0.71.5 2024