vuestorefront / vue-storefront

Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
https://www.alokai.com
MIT License
10.61k stars 2.08k forks source link

"multisiteCommonCart": true has no effect. #2595

Closed thomasthune closed 5 years ago

thomasthune commented 5 years ago

Current behavior

Setting "multisiteCommonCart": true, has no effect

Expected behavior

Setting "multisiteCommonCart": true, should force the user to have different carts on the different stores respectively

Steps to reproduce the issue

Setup multistore environment with: "multisiteCommonCart": true

Visit each store, observe localStorage in devtools, only "default" non-prefixed cart storage will be visible: screenshot-1552651974

Repository

@vue-storefront: v.1.8.3

Can you handle fixing this bug by yourself?

No, not at the moment

Additional information

The initializing of $db.cartsCollection is run in the beforeRegistration hook in the cart module. This happens as part of createApp (core/app.ts) and during this the currentStoreView is always initialized with null. Later during bootstrap, either client-entry og server-entry the storeview is changed, with prepareStoreView. Only problem is that the $db.cartsCollection isnt updated, since the beforeRegistration hook is not fired again after createApp().

Like with the syncTask storage it should be initialized when the store changes (core/lib/multistore.ts:76). There are a couple of modules who would rely on this behaviour: cms, user, cart, compare, checkout.

filrak commented 5 years ago

On it ;)