Magento 2.2.x: Persistent Checkout can't be disabled












0















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.
enter image description here



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.










share|improve this question























  • 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
















0















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.
enter image description here



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.










share|improve this question























  • 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














0












0








0








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.
enter image description here



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.










share|improve this question














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.
enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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










1 Answer
1






active

oldest

votes


















0














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();
}
}
}





share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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();
    }
    }
    }





    share|improve this answer




























      0














      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();
      }
      }
      }





      share|improve this answer


























        0












        0








        0







        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();
        }
        }
        }





        share|improve this answer













        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();
        }
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 22 at 3:31









        fudufudu

        37611




        37611






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            William S. Burroughs

            Eda skans

            1924