Currency switching doesn't work for anonymous users with empty cart

Created on 22 March 2019, over 5 years ago
Updated 28 November 2023, 12 months ago

Problem

Whenever an anyonymous (not logged in) user selects a different currency in the currency switcher block, the page reloads but currency remains the same. Same thing works perfectly after a product is placed in the cart or if the user is logged in.

Steps to reproduce:
- Install Drupal, install and enable Commerce, Commerce Price, Commerce Currency Resolver 8.x-1.41
- In Commerce settings add a Store, enable at least 2 currencies
- Add a Commerce product, set price to something
- In this module's settings set Currency mapping to "Cookie (currency block selector)"
- Place currency block somewhere on the page
- Open product page as anonymous user
- Try switching currency by selecting another currency in the block's dropdown
- Page reloads, currency displayed on the product and shown in the block dropdown remains the same.
- Place something in cart. After the page reloads, your previous currency selection is applied, and currency switching suddenly works as it should.

Further info/tips
- The problem doesn't show on my dev site where page and render cache is disabled in settings.local.php so I suspect this is something cache related.
- The problem also doesn't show if the user is logged in.
- Might be something with sessions / Drupal not actually starting a session for anonymous users.

Proposed resolution

I don't have the knowledge to debug / solve this, sorry.
Maybe make force session start for anonymous users when switching currency? (Or whatever happens on 'add to cart' that makes it work afterwards.)

๐Ÿ› Bug report
Status

Fixed

Version

1.41

Component

Code

Created by

๐Ÿ‡ญ๐Ÿ‡บHungary dr. gubรณ

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024