Magento 2.2.x: Persistent Checkout can't be disabled
The problem is even when i disable the "persistent checkout", it still work as normal.
Its a magento default module, so i think this is a magento 2 bug.

After a day working on this, i still don't know how this work. I mean i guess they use cookie or session to store the cart after customer log out.
Then after guest login, they will use that session or cookie to update the cart.
But i don't know how they do that.
The module is "module-persistent" (default magento module).
Thanks.
magento2 checkout cart session persistent
add a comment |
The problem is even when i disable the "persistent checkout", it still work as normal.
Its a magento default module, so i think this is a magento 2 bug.

After a day working on this, i still don't know how this work. I mean i guess they use cookie or session to store the cart after customer log out.
Then after guest login, they will use that session or cookie to update the cart.
But i don't know how they do that.
The module is "module-persistent" (default magento module).
Thanks.
magento2 checkout cart session persistent
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34
add a comment |
The problem is even when i disable the "persistent checkout", it still work as normal.
Its a magento default module, so i think this is a magento 2 bug.

After a day working on this, i still don't know how this work. I mean i guess they use cookie or session to store the cart after customer log out.
Then after guest login, they will use that session or cookie to update the cart.
But i don't know how they do that.
The module is "module-persistent" (default magento module).
Thanks.
magento2 checkout cart session persistent
The problem is even when i disable the "persistent checkout", it still work as normal.
Its a magento default module, so i think this is a magento 2 bug.

After a day working on this, i still don't know how this work. I mean i guess they use cookie or session to store the cart after customer log out.
Then after guest login, they will use that session or cookie to update the cart.
But i don't know how they do that.
The module is "module-persistent" (default magento module).
Thanks.
magento2 checkout cart session persistent
magento2 checkout cart session persistent
asked Jan 21 at 14:18
fudufudu
37611
37611
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34
add a comment |
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
Well, so after a day looking for solution, i've found something.
But this is only a temporary solution.
So here is the idea:
We override the magento/customer/account/logout by plugin, then we will truncate the cart.
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerControllerAccountLogout">
<plugin name="remove_cart_before_logout" type="FuduCustomerPluginControllerAccountLogout" sortOrder="1" />
</type>
</config>
Plugin/Controller/Account/Logout
<?php
namespace FuduCustomerPluginControllerAccount;
use MagentoCustomerControllerAccountLogout as CustomerLogout;
class Logout
{
public function __construct(
MagentoCheckoutModelSession $session,
MagentoCheckoutModelCart $cart,
MagentoPersistentHelperData $persistentData
){
$this->_session = $session;
$this->cart = $cart;
$this->persistentData = $persistentData;
}
public function beforeExecute(CustomerLogout $subject)
{
if(!$this->persistentData->isEnabled()){
$this->cart->truncate()->save();
}
}
}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258590%2fmagento-2-2-x-persistent-checkout-cant-be-disabled%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, so after a day looking for solution, i've found something.
But this is only a temporary solution.
So here is the idea:
We override the magento/customer/account/logout by plugin, then we will truncate the cart.
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerControllerAccountLogout">
<plugin name="remove_cart_before_logout" type="FuduCustomerPluginControllerAccountLogout" sortOrder="1" />
</type>
</config>
Plugin/Controller/Account/Logout
<?php
namespace FuduCustomerPluginControllerAccount;
use MagentoCustomerControllerAccountLogout as CustomerLogout;
class Logout
{
public function __construct(
MagentoCheckoutModelSession $session,
MagentoCheckoutModelCart $cart,
MagentoPersistentHelperData $persistentData
){
$this->_session = $session;
$this->cart = $cart;
$this->persistentData = $persistentData;
}
public function beforeExecute(CustomerLogout $subject)
{
if(!$this->persistentData->isEnabled()){
$this->cart->truncate()->save();
}
}
}
add a comment |
Well, so after a day looking for solution, i've found something.
But this is only a temporary solution.
So here is the idea:
We override the magento/customer/account/logout by plugin, then we will truncate the cart.
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerControllerAccountLogout">
<plugin name="remove_cart_before_logout" type="FuduCustomerPluginControllerAccountLogout" sortOrder="1" />
</type>
</config>
Plugin/Controller/Account/Logout
<?php
namespace FuduCustomerPluginControllerAccount;
use MagentoCustomerControllerAccountLogout as CustomerLogout;
class Logout
{
public function __construct(
MagentoCheckoutModelSession $session,
MagentoCheckoutModelCart $cart,
MagentoPersistentHelperData $persistentData
){
$this->_session = $session;
$this->cart = $cart;
$this->persistentData = $persistentData;
}
public function beforeExecute(CustomerLogout $subject)
{
if(!$this->persistentData->isEnabled()){
$this->cart->truncate()->save();
}
}
}
add a comment |
Well, so after a day looking for solution, i've found something.
But this is only a temporary solution.
So here is the idea:
We override the magento/customer/account/logout by plugin, then we will truncate the cart.
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerControllerAccountLogout">
<plugin name="remove_cart_before_logout" type="FuduCustomerPluginControllerAccountLogout" sortOrder="1" />
</type>
</config>
Plugin/Controller/Account/Logout
<?php
namespace FuduCustomerPluginControllerAccount;
use MagentoCustomerControllerAccountLogout as CustomerLogout;
class Logout
{
public function __construct(
MagentoCheckoutModelSession $session,
MagentoCheckoutModelCart $cart,
MagentoPersistentHelperData $persistentData
){
$this->_session = $session;
$this->cart = $cart;
$this->persistentData = $persistentData;
}
public function beforeExecute(CustomerLogout $subject)
{
if(!$this->persistentData->isEnabled()){
$this->cart->truncate()->save();
}
}
}
Well, so after a day looking for solution, i've found something.
But this is only a temporary solution.
So here is the idea:
We override the magento/customer/account/logout by plugin, then we will truncate the cart.
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerControllerAccountLogout">
<plugin name="remove_cart_before_logout" type="FuduCustomerPluginControllerAccountLogout" sortOrder="1" />
</type>
</config>
Plugin/Controller/Account/Logout
<?php
namespace FuduCustomerPluginControllerAccount;
use MagentoCustomerControllerAccountLogout as CustomerLogout;
class Logout
{
public function __construct(
MagentoCheckoutModelSession $session,
MagentoCheckoutModelCart $cart,
MagentoPersistentHelperData $persistentData
){
$this->_session = $session;
$this->cart = $cart;
$this->persistentData = $persistentData;
}
public function beforeExecute(CustomerLogout $subject)
{
if(!$this->persistentData->isEnabled()){
$this->cart->truncate()->save();
}
}
}
answered Jan 22 at 3:31
fudufudu
37611
37611
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258590%2fmagento-2-2-x-persistent-checkout-cant-be-disabled%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have you clean the configuration cache?
– Philipp Sander
Jan 21 at 14:24
Yes i did serveral time, as i said, i was working on this all day long, so the first thing i have thinking of is "clear cache" :D
– fudu
Jan 21 at 14:34