# Magento2 启用持久购物车

**URL:** https://forum.magentochina.org/t/magento2-%E5%90%AF%E7%94%A8%E6%8C%81%E4%B9%85%E8%B4%AD%E7%89%A9%E8%BD%A6/850
**Category:** Magento 2.X
**Tags:** 教程, magento2
**Created:** [2020 年10 月 10 日 04:31 UTC](https://forum.magentochina.org/t/magento2-%E5%90%AF%E7%94%A8%E6%8C%81%E4%B9%85%E8%B4%AD%E7%89%A9%E8%BD%A6/850 "2020-10-10T04:31:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### 作者： ![Vicky](https://forum.magentochina.org/letter_avatar_proxy/v4/letter/v/b19c9b/32.png) [@Vicky](https://forum.magentochina.org/u/Vicky)
#### 发布日期： [2020 年10 月 10 日 04:31 UTC](https://forum.magentochina.org/t/magento2-%E5%90%AF%E7%94%A8%E6%8C%81%E4%B9%85%E8%B4%AD%E7%89%A9%E8%BD%A6/850/1 "2020-10-10T04:31:26Z")

</div>

在 Magento2 中，持久购物车是一个减少购物车放弃的相对高效的功能。它可以把没有结账的商品存储在购物车中，甚至是未登录也可以。

### 通过持久购物车来减少购物车放弃率

大多数的在线客户没有最终决定是否购买，尽管他们对产品感兴趣。这种情况下，他们会把这些商品放在购物车中。持久购物车可以不用再搜索或者用户再次回来的情况下，让未完成的付款继续。

尤其是不用关系下单的设备，持久购物车可以根据用户 ID 来精确的更新购物车。因此， 不管设备是平板还是手机都可以保持交易状态来增强购物体验。

### 如何启用持久购物车

按照以下步骤来启用持久购物车：

- 登录 Magento2 后天，找到菜单 Stores → Configuration → Customers → Persistent Shopping Cart，选择 Yes 这个选项；

- 让 Use system value 这个选项是补选中状态；

- 在 Persistence Lifetime 这里设置更新持久 cookie 的时间。默认值是 31,536,000 秒；

- 启用 Remember Me 这个选项（是一个 checkbox），用于保存购物车信息，会展示在登录页面中。

- 当用户登录时，是否给 “Remember Me” 设置默认选项是可选的；

- 给 “Clear Persistence on Sign Out” 设置 “No” 用于保存购物车的所有信息。

- 然后点击 Save 按钮来启用前台持久购物车；

- 如果在会话（session） cookie 过期时想要保持持久的 cookie，给 “Persist Shopping Cart” 设置 “Yes” 。

 ![image](https://forum.magentochina.org/uploads/default/original/1X/5855b25002cee90cf3d1bd95d42a98b9a8616ccb.png)

## 本教程翻译自Mageplaza模块开发系列，其他内容请点击下面链接:

> [@Magento2模块开发中文教程索引](https://forum.magentochina.org/t/magento2%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91%E4%B8%AD%E6%96%87%E6%95%99%E7%A8%8B%E7%B4%A2%E5%BC%95/36):
>
> 本文翻译自mageplaza的Magento2模块开发教程,而且正在翻译中. 翻译也是非常好的学习方式，希望下列表中还有我们没有翻译，而你又想分享的内容,请发表文章之后，在下面附上地址。 如果觉得本站翻译得内容对您有帮助，又没有时间帮助翻译回馈社区.请打赏我们，您的支持是我们的动力: 转载说明:非常欢迎转载，但是必须保证文章的完整性并附上原文地址和翻译原文的地址，保证阅读者不会产生歧义. 目录索引: 索 引 中 文 原 文 1 [Magento2如何创建模块](https://forum.magentochina.org/t/Magento-2%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E6%A8%A1%E5%9D%97%E6%95%99%E7%A8%8B/38)[How to Create Module in Magento 2](https://www.mageplaza.com/kb/how-create-hello-world-module-magento-2.html) 2 [控制器详解](https://forum.magentochina.org/t/Magento-2%E6%8E%A7%E5%88%B6%E5%99%A8%E8%AF%A6%E8%A7%A3%E6%95%99%E7%A8%8B/39)[Create Controllers](https://www.mageplaza.com/magento-2-module-development/how-to-create-controllers-magento-2.html) 3 [CRUD 模型](https://forum.magentochina.org/t/Magento2-CRUD%E6%A8%A1%E5%9E%8B%E8%B5%84%E6%BA%90%E9%9B%86%E5%90%88%E5%B7%A5%E5%8E%82%E5%AF%B9%E8%B1%A1%E8%AF%A6%E8%A7%A3%E6%95%99%E7%A8%8B/43)[CRUD Models](https://www.mageplaza.com/magento-2-module-development/how-to-create-crud-model-magento-2.html) 4 [视图层:块,布局和模板](https://forum.magentochina.org/t/%E8%A7%86%E5%9B%BE%E5%B1%82%E5%9D%97%E5%B8%83%E5%B1%80%E5%92%8C%E6%A8%A1%E6%9D%BF%E6%A8%A1%E6%9D%BF%E6%95%99%E7%A8%8B/50/1)[View: Block, Layouts and templates](https://www.mageplaza.com/magento-2-module-development/view-block-layout-template-magento-2.html) 5 [配置system.xml](https://forum.magentochina.org/t/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6systemxml/55)[Configuration - System.xm…](https://www.mageplaza.com/magento-2-module-development/create-system-xml-configuration-magento-2.html)
