关于magento2.2 游客刷新页面 地址信息丢失问题

2.43K 浏览开发笔记

关于magento2.2 游客刷新页面 地址信息丢失问题

Ps:这个问题在2.3版本中已经被解决

禁用持久化购物车可以解决这个问题 Stores -> Configuration -> Customers -> Persistent Shopping Cart -> Enable Persistence

magento/module-persistent/Observer/CheckExpirePersistentQuoteObserver.php中有一些检查,如果通过,那么就会将删除mage-cache-sessidcookie

magento/module-customer/view/frontend/web/js/customer-data.js文件里

    /**
     * Invalidate Cache By Close Cookie Session
     */
    invalidateCacheByCloseCookieSession = function () {
        if (!$.cookieStorage.isSet('mage-cache-sessid')) {
            $.cookieStorage.set('mage-cache-sessid', true);
            storage.removeAll();
        }
    };

这里的storage.removeAll();将清空localstorage。

如果您不想禁用持久性购物车,则需要查看Observer中的检查 (ps:现在没有时间去检查这个,有时间的大佬可以检查下补充一下)

0