Build the session cache key
Must read
The key now carries the customer id only. Read it with the currency selector in mind: a switch must not find the previous session.
src/checkout/session.ts| 38 | 38 | const cache = getCache('checkout'); | |
| 39 | - | const key = `checkout:${user.id}`; | |
| 39 | + | const key = `checkout:${user.id}:${currency}`; | |
| 40 | 40 | const cached = await cache.get(key); | |
| 41 | 41 | if (cached) return cached; | |
| 42 | - | const session = await createSession(user); | |
| 42 | + | const session = await createSession(user, currency); | |
| 43 | 43 | await cache.set(key, session, { ttl: SESSION_TTL }); | |
| 44 | 44 | return session; | |
| 45 | 45 | } |