vuestorefront / vue-storefront-1

The open-source frontend for any eCommerce. Built with a PWA and headless approach, using a modern JS stack. We have custom integrations with Magento, commercetools, Shopware and Shopify and total coverage is just a matter of time. The API approach also allows you to merge VSF with any third-party tool like CMS, payment gateways or analytics. Newest updates: https://blog.vuestorefront.io. Always Open Source, MIT license.
https://www.vuestorefront.io
MIT License
19 stars 13 forks source link

Option for sharing user storage across stores in multistore #199

Closed bloodf closed 3 years ago

bloodf commented 3 years ago

From vue-storefront created by rain2o: vuestorefront/vue-storefront#5314

What is the motivation for adding / enhancing this feature?

When using the multistore feature, there is a config option for commonCache, which will determine if local storage will store data per store or not. This is very useful for localization. However, sometimes the user data might not need to be stored separately per store.

For example, if using Magento 2 as the backend, you have the option to allow customer accounts to be shared across all websites and stores, or require customers to create a new account per website. We currently have our shop setup to share the user accounts across all websites in Magento.

This results in unnecessary duplication of storage for the user data. This also means a different customer token is created and stored per store in Vue Storefront, but in reality we only need one per user. We saw some strange behavior when switching stores as a logged-in user.

A simple solution to this could be to add a new option in the configuration, for example storeViews.commonUserCache. Then, in core/modules/user/index.ts we can change StorageManager.init('user') to StorageManager.init('user', !config.storeViews.commonUserCache).

What are the acceptance criteria

Version of Vue Storefront

Can you complete this feature request by yourself?

Additional information

If there are better solutions for this please let me know. Otherwise I can work on this using the solution I suggested above.