Shopping cart is not clearing on the cart page












1














After I updated from Magento version 2.2.3 to 2.2.6 the shopping cart stopped clearing after I click "Clear Shopping Cart" on the cart page.



After I click the button, the page reloads but everything remains the same.



I am using Ultimo theme but I have checked and it doesn't overwrite this behavior anyhow.



What could be the possible issue and where should I start my investigation from?










share|improve this question






















  • I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
    – Haya
    Nov 24 '18 at 12:20












  • @Haya Check phagento answer
    – Ilja Davidovs
    Nov 26 '18 at 10:46
















1














After I updated from Magento version 2.2.3 to 2.2.6 the shopping cart stopped clearing after I click "Clear Shopping Cart" on the cart page.



After I click the button, the page reloads but everything remains the same.



I am using Ultimo theme but I have checked and it doesn't overwrite this behavior anyhow.



What could be the possible issue and where should I start my investigation from?










share|improve this question






















  • I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
    – Haya
    Nov 24 '18 at 12:20












  • @Haya Check phagento answer
    – Ilja Davidovs
    Nov 26 '18 at 10:46














1












1








1


1





After I updated from Magento version 2.2.3 to 2.2.6 the shopping cart stopped clearing after I click "Clear Shopping Cart" on the cart page.



After I click the button, the page reloads but everything remains the same.



I am using Ultimo theme but I have checked and it doesn't overwrite this behavior anyhow.



What could be the possible issue and where should I start my investigation from?










share|improve this question













After I updated from Magento version 2.2.3 to 2.2.6 the shopping cart stopped clearing after I click "Clear Shopping Cart" on the cart page.



After I click the button, the page reloads but everything remains the same.



I am using Ultimo theme but I have checked and it doesn't overwrite this behavior anyhow.



What could be the possible issue and where should I start my investigation from?







magento2 cart






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 3 '18 at 7:32









Ilja Davidovs

104




104












  • I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
    – Haya
    Nov 24 '18 at 12:20












  • @Haya Check phagento answer
    – Ilja Davidovs
    Nov 26 '18 at 10:46


















  • I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
    – Haya
    Nov 24 '18 at 12:20












  • @Haya Check phagento answer
    – Ilja Davidovs
    Nov 26 '18 at 10:46
















I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
– Haya
Nov 24 '18 at 12:20






I am having same issue with Magento 2.2.6 and Latest version of Ultimo theme. Did you find a solution? This is exception I am seeing in log file. main.CRITICAL: Requested product doesn't exist {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Requested product doesn't exist at /home/web/site/public_html/vendor/magento/module-catalog/Model/ProductRepository.php:271)
– Haya
Nov 24 '18 at 12:20














@Haya Check phagento answer
– Ilja Davidovs
Nov 26 '18 at 10:46




@Haya Check phagento answer
– Ilja Davidovs
Nov 26 '18 at 10:46










4 Answers
4






active

oldest

votes


















5














I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7



So from



action.clear


It should be



.action.clear


Note: Please don't edit the file in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml directly.






share|improve this answer































    2














    When a user clicks on Clear Shopping Cart button then you have to check below:




    • On click on this button the
      http://{Example.com}/checkout/cart/updatePost/ should hit.


    • This URL must hit via POST request.



      This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart




    FORM DATA should like when to click on Clear Shopping Cart



    form_key: 4VQpuhYHzS9dOY3P
    cart[15][qty]: 1
    cart[17][qty]: 1
    update_cart_action: empty_cart


    Where 15,17 are cart item id.



    If those are available or exist then the exception is not happening.
    You check error, check the exception log or changes



    $this->messageManager->addException($exception, __('We can't update the shopping cart.'));



    to



    $this->messageManager->addError($exception->getMessage()





    share|improve this answer





















    • update_cart_action parameter is missing. Is it related to JavaScript?
      – Ilja Davidovs
      Oct 3 '18 at 9:32












    • @Amit Bera please check my answer
      – Ranganathan
      Oct 6 '18 at 5:05



















    0














    The Problem is 'update_cart_action' Parameter is not sending because Mageno developers added 'Magento_Checkout/js/action/update-shopping-cart' js function for validation. They Submit the form in this file. So the submit button value param is not sending. Add the hidden field with submit button name in



    Magento_Checkout/templates/cart/item/form.phtml


    <input type="hidden" id="update_cart_action_hidden" name="update_cart_action" value="">


    And assign the value of submit button using onClick event to the hidden field



    $('.update-cart-action').click(function(){
    $('#update_cart_action_hidden').val($(this).val());
    });


    Hope this will work






    share|improve this answer































      0














      Checkout Cart Page >> Clear Shopping Cart button should have alert to the users if they want to clear or not.



      Here I am overriding form.phtml in my theme.



      app/design/frontend/Namespace/yourthemename/Magento_Checkout/templates/cart/form.phtml




      form.phtml





      <?php
      /**
      * Copyright © Magento, Inc. All rights reserved.
      * See COPYING.txt for license details.
      */

      // @codingStandardsIgnoreFile

      /** @var $block MagentoCheckoutBlockCartGrid */
      ?>
      <?php $mergedCells = ($this->helper('MagentoTaxHelperData')->displayCartBothPrices() ? 2 : 1); ?>
      <?= $block->getChildHtml('form_before') ?>
      <form action="<?= /* @escapeNotVerified */ $block->getUrl('checkout/cart/updatePost') ?>"
      method="post"
      id="form-validate"
      data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
      {"validationURL" : "/checkout/cart/updateItemQty"}
      }'
      class="form form-cart">
      <?= $block->getBlockHtml('formkey') ?>
      <div class="cart table-wrapper<?= $mergedCells == 2 ? ' detailed' : '' ?>">
      <?php if ($block->getPagerHtml()): ?>
      <div class="cart-products-toolbar cart-products-toolbar-top toolbar" data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?></div>
      <?php endif ?>
      <table id="shopping-cart-table"
      class="cart items data table"
      data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
      "updateCartActionContainer": "#update_cart_action_container"}}'>
      <caption role="heading" aria-level="2" class="table-caption"><?= /* @escapeNotVerified */ __('Shopping Cart Items') ?></caption>
      <thead>
      <tr>
      <th class="col item" scope="col"><span><?= /* @escapeNotVerified */ __('Item') ?></span></th>
      <th class="col price" scope="col"><span><?= /* @escapeNotVerified */ __('Price') ?></span></th>
      <th class="col qty" scope="col"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
      <th class="col subtotal" scope="col"><span><?= /* @escapeNotVerified */ __('Subtotal') ?></span></th>
      </tr>
      </thead>
      <?php foreach ($block->getItems() as $_item): ?>
      <?= $block->getItemHtml($_item) ?>
      <?php endforeach ?>
      </table>
      <?php if ($block->getPagerHtml()): ?>
      <div class="cart-products-toolbar cart-products-toolbar-bottom toolbar" data-attribute="cart-products-toolbar-bottom"><?= $block->getPagerHtml() ?></div>
      <?php endif ?>
      </div>
      <div class="cart main actions">
      <?php if ($block->getContinueShoppingUrl()): ?>
      <a class="action continue"
      href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>"
      title="<?= $block->escapeHtml(__('Continue Shopping')) ?>">
      <span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span>
      </a>
      <?php endif; ?>
      <button type="button"
      title="<?php echo $block->escapeHtml(__('Clear Shopping Cart')); ?>"
      class="action clear" id="cp-empty_cart_button">
      <span><?php /* @escapeNotVerified */
      echo __('Clear Shopping Cart'); ?></span>
      </button>
      <button type="submit"
      name="update_cart_action"
      data-cart-empty=""
      value="empty_cart"
      title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
      class="action clear" id="empty_cart_button" style="display: none;">
      <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
      </button>
      <button type="submit"
      name="update_cart_action"
      data-cart-item-update=""
      value="update_qty"
      title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
      class="action update">
      <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
      </button>
      <input type="hidden" value="" id="update_cart_action_container" data-cart-item-update=""/>
      </div>
      </form>
      <?= $block->getChildHtml('checkout.cart.order.actions') ?>
      <?= $block->getChildHtml('shopping.cart.table.after') ?>
      <script type="text/javascript">
      require([
      'jquery',
      'Magento_Ui/js/modal/alert',
      'Magento_Ui/js/modal/confirm'
      ], function ($, alertt, confirmation) {
      $(document).ready(function () {
      $('.cp-action-accept').parents('aside').addClass('confirm');
      $('#cp-empty_cart_button').on('click', function (event) {
      event.preventDefault();
      confirmation({
      title: '',
      content: 'Are you sure to remove products from cart ?',
      actions: {
      confirm: function () {
      window.location.href = '<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart/updatePost'); ?>';
      },
      cancel: function () {
      }
      },
      buttons: [{
      text: $.mage.__('OK'),
      class: 'action secondary cp-action-accept',
      /**
      * Click handler.
      */
      click: function (event) {
      this.closeModal(event, true);
      $('#empty_cart_button').trigger('click');
      }
      },
      {
      text: $.mage.__('Cancel'),
      class: 'action secondary action-dismiss',
      /**
      * Click handler.
      */
      click: function (event) {
      this.closeModal(event);
      }
      }
      ]
      });
      });
      });
      });
      </script>


      Output will be like this :-



      enter image description here






      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%2f244815%2fshopping-cart-is-not-clearing-on-the-cart-page%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7



        So from



        action.clear


        It should be



        .action.clear


        Note: Please don't edit the file in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml directly.






        share|improve this answer




























          5














          I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7



          So from



          action.clear


          It should be



          .action.clear


          Note: Please don't edit the file in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml directly.






          share|improve this answer


























            5












            5








            5






            I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7



            So from



            action.clear


            It should be



            .action.clear


            Note: Please don't edit the file in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml directly.






            share|improve this answer














            I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7



            So from



            action.clear


            It should be



            .action.clear


            Note: Please don't edit the file in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml directly.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 13 '18 at 9:08

























            answered Nov 9 '18 at 2:04









            phagento

            30427




            30427

























                2














                When a user clicks on Clear Shopping Cart button then you have to check below:




                • On click on this button the
                  http://{Example.com}/checkout/cart/updatePost/ should hit.


                • This URL must hit via POST request.



                  This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart




                FORM DATA should like when to click on Clear Shopping Cart



                form_key: 4VQpuhYHzS9dOY3P
                cart[15][qty]: 1
                cart[17][qty]: 1
                update_cart_action: empty_cart


                Where 15,17 are cart item id.



                If those are available or exist then the exception is not happening.
                You check error, check the exception log or changes



                $this->messageManager->addException($exception, __('We can't update the shopping cart.'));



                to



                $this->messageManager->addError($exception->getMessage()





                share|improve this answer





















                • update_cart_action parameter is missing. Is it related to JavaScript?
                  – Ilja Davidovs
                  Oct 3 '18 at 9:32












                • @Amit Bera please check my answer
                  – Ranganathan
                  Oct 6 '18 at 5:05
















                2














                When a user clicks on Clear Shopping Cart button then you have to check below:




                • On click on this button the
                  http://{Example.com}/checkout/cart/updatePost/ should hit.


                • This URL must hit via POST request.



                  This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart




                FORM DATA should like when to click on Clear Shopping Cart



                form_key: 4VQpuhYHzS9dOY3P
                cart[15][qty]: 1
                cart[17][qty]: 1
                update_cart_action: empty_cart


                Where 15,17 are cart item id.



                If those are available or exist then the exception is not happening.
                You check error, check the exception log or changes



                $this->messageManager->addException($exception, __('We can't update the shopping cart.'));



                to



                $this->messageManager->addError($exception->getMessage()





                share|improve this answer





















                • update_cart_action parameter is missing. Is it related to JavaScript?
                  – Ilja Davidovs
                  Oct 3 '18 at 9:32












                • @Amit Bera please check my answer
                  – Ranganathan
                  Oct 6 '18 at 5:05














                2












                2








                2






                When a user clicks on Clear Shopping Cart button then you have to check below:




                • On click on this button the
                  http://{Example.com}/checkout/cart/updatePost/ should hit.


                • This URL must hit via POST request.



                  This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart




                FORM DATA should like when to click on Clear Shopping Cart



                form_key: 4VQpuhYHzS9dOY3P
                cart[15][qty]: 1
                cart[17][qty]: 1
                update_cart_action: empty_cart


                Where 15,17 are cart item id.



                If those are available or exist then the exception is not happening.
                You check error, check the exception log or changes



                $this->messageManager->addException($exception, __('We can't update the shopping cart.'));



                to



                $this->messageManager->addError($exception->getMessage()





                share|improve this answer












                When a user clicks on Clear Shopping Cart button then you have to check below:




                • On click on this button the
                  http://{Example.com}/checkout/cart/updatePost/ should hit.


                • This URL must hit via POST request.



                  This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart




                FORM DATA should like when to click on Clear Shopping Cart



                form_key: 4VQpuhYHzS9dOY3P
                cart[15][qty]: 1
                cart[17][qty]: 1
                update_cart_action: empty_cart


                Where 15,17 are cart item id.



                If those are available or exist then the exception is not happening.
                You check error, check the exception log or changes



                $this->messageManager->addException($exception, __('We can't update the shopping cart.'));



                to



                $this->messageManager->addError($exception->getMessage()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 3 '18 at 7:53









                Amit Bera

                57.2k1374170




                57.2k1374170












                • update_cart_action parameter is missing. Is it related to JavaScript?
                  – Ilja Davidovs
                  Oct 3 '18 at 9:32












                • @Amit Bera please check my answer
                  – Ranganathan
                  Oct 6 '18 at 5:05


















                • update_cart_action parameter is missing. Is it related to JavaScript?
                  – Ilja Davidovs
                  Oct 3 '18 at 9:32












                • @Amit Bera please check my answer
                  – Ranganathan
                  Oct 6 '18 at 5:05
















                update_cart_action parameter is missing. Is it related to JavaScript?
                – Ilja Davidovs
                Oct 3 '18 at 9:32






                update_cart_action parameter is missing. Is it related to JavaScript?
                – Ilja Davidovs
                Oct 3 '18 at 9:32














                @Amit Bera please check my answer
                – Ranganathan
                Oct 6 '18 at 5:05




                @Amit Bera please check my answer
                – Ranganathan
                Oct 6 '18 at 5:05











                0














                The Problem is 'update_cart_action' Parameter is not sending because Mageno developers added 'Magento_Checkout/js/action/update-shopping-cart' js function for validation. They Submit the form in this file. So the submit button value param is not sending. Add the hidden field with submit button name in



                Magento_Checkout/templates/cart/item/form.phtml


                <input type="hidden" id="update_cart_action_hidden" name="update_cart_action" value="">


                And assign the value of submit button using onClick event to the hidden field



                $('.update-cart-action').click(function(){
                $('#update_cart_action_hidden').val($(this).val());
                });


                Hope this will work






                share|improve this answer




























                  0














                  The Problem is 'update_cart_action' Parameter is not sending because Mageno developers added 'Magento_Checkout/js/action/update-shopping-cart' js function for validation. They Submit the form in this file. So the submit button value param is not sending. Add the hidden field with submit button name in



                  Magento_Checkout/templates/cart/item/form.phtml


                  <input type="hidden" id="update_cart_action_hidden" name="update_cart_action" value="">


                  And assign the value of submit button using onClick event to the hidden field



                  $('.update-cart-action').click(function(){
                  $('#update_cart_action_hidden').val($(this).val());
                  });


                  Hope this will work






                  share|improve this answer


























                    0












                    0








                    0






                    The Problem is 'update_cart_action' Parameter is not sending because Mageno developers added 'Magento_Checkout/js/action/update-shopping-cart' js function for validation. They Submit the form in this file. So the submit button value param is not sending. Add the hidden field with submit button name in



                    Magento_Checkout/templates/cart/item/form.phtml


                    <input type="hidden" id="update_cart_action_hidden" name="update_cart_action" value="">


                    And assign the value of submit button using onClick event to the hidden field



                    $('.update-cart-action').click(function(){
                    $('#update_cart_action_hidden').val($(this).val());
                    });


                    Hope this will work






                    share|improve this answer














                    The Problem is 'update_cart_action' Parameter is not sending because Mageno developers added 'Magento_Checkout/js/action/update-shopping-cart' js function for validation. They Submit the form in this file. So the submit button value param is not sending. Add the hidden field with submit button name in



                    Magento_Checkout/templates/cart/item/form.phtml


                    <input type="hidden" id="update_cart_action_hidden" name="update_cart_action" value="">


                    And assign the value of submit button using onClick event to the hidden field



                    $('.update-cart-action').click(function(){
                    $('#update_cart_action_hidden').val($(this).val());
                    });


                    Hope this will work







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Oct 6 '18 at 6:57

























                    answered Oct 6 '18 at 5:05









                    Ranganathan

                    498316




                    498316























                        0














                        Checkout Cart Page >> Clear Shopping Cart button should have alert to the users if they want to clear or not.



                        Here I am overriding form.phtml in my theme.



                        app/design/frontend/Namespace/yourthemename/Magento_Checkout/templates/cart/form.phtml




                        form.phtml





                        <?php
                        /**
                        * Copyright © Magento, Inc. All rights reserved.
                        * See COPYING.txt for license details.
                        */

                        // @codingStandardsIgnoreFile

                        /** @var $block MagentoCheckoutBlockCartGrid */
                        ?>
                        <?php $mergedCells = ($this->helper('MagentoTaxHelperData')->displayCartBothPrices() ? 2 : 1); ?>
                        <?= $block->getChildHtml('form_before') ?>
                        <form action="<?= /* @escapeNotVerified */ $block->getUrl('checkout/cart/updatePost') ?>"
                        method="post"
                        id="form-validate"
                        data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
                        {"validationURL" : "/checkout/cart/updateItemQty"}
                        }'
                        class="form form-cart">
                        <?= $block->getBlockHtml('formkey') ?>
                        <div class="cart table-wrapper<?= $mergedCells == 2 ? ' detailed' : '' ?>">
                        <?php if ($block->getPagerHtml()): ?>
                        <div class="cart-products-toolbar cart-products-toolbar-top toolbar" data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?></div>
                        <?php endif ?>
                        <table id="shopping-cart-table"
                        class="cart items data table"
                        data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
                        "updateCartActionContainer": "#update_cart_action_container"}}'>
                        <caption role="heading" aria-level="2" class="table-caption"><?= /* @escapeNotVerified */ __('Shopping Cart Items') ?></caption>
                        <thead>
                        <tr>
                        <th class="col item" scope="col"><span><?= /* @escapeNotVerified */ __('Item') ?></span></th>
                        <th class="col price" scope="col"><span><?= /* @escapeNotVerified */ __('Price') ?></span></th>
                        <th class="col qty" scope="col"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
                        <th class="col subtotal" scope="col"><span><?= /* @escapeNotVerified */ __('Subtotal') ?></span></th>
                        </tr>
                        </thead>
                        <?php foreach ($block->getItems() as $_item): ?>
                        <?= $block->getItemHtml($_item) ?>
                        <?php endforeach ?>
                        </table>
                        <?php if ($block->getPagerHtml()): ?>
                        <div class="cart-products-toolbar cart-products-toolbar-bottom toolbar" data-attribute="cart-products-toolbar-bottom"><?= $block->getPagerHtml() ?></div>
                        <?php endif ?>
                        </div>
                        <div class="cart main actions">
                        <?php if ($block->getContinueShoppingUrl()): ?>
                        <a class="action continue"
                        href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>"
                        title="<?= $block->escapeHtml(__('Continue Shopping')) ?>">
                        <span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span>
                        </a>
                        <?php endif; ?>
                        <button type="button"
                        title="<?php echo $block->escapeHtml(__('Clear Shopping Cart')); ?>"
                        class="action clear" id="cp-empty_cart_button">
                        <span><?php /* @escapeNotVerified */
                        echo __('Clear Shopping Cart'); ?></span>
                        </button>
                        <button type="submit"
                        name="update_cart_action"
                        data-cart-empty=""
                        value="empty_cart"
                        title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
                        class="action clear" id="empty_cart_button" style="display: none;">
                        <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
                        </button>
                        <button type="submit"
                        name="update_cart_action"
                        data-cart-item-update=""
                        value="update_qty"
                        title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
                        class="action update">
                        <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
                        </button>
                        <input type="hidden" value="" id="update_cart_action_container" data-cart-item-update=""/>
                        </div>
                        </form>
                        <?= $block->getChildHtml('checkout.cart.order.actions') ?>
                        <?= $block->getChildHtml('shopping.cart.table.after') ?>
                        <script type="text/javascript">
                        require([
                        'jquery',
                        'Magento_Ui/js/modal/alert',
                        'Magento_Ui/js/modal/confirm'
                        ], function ($, alertt, confirmation) {
                        $(document).ready(function () {
                        $('.cp-action-accept').parents('aside').addClass('confirm');
                        $('#cp-empty_cart_button').on('click', function (event) {
                        event.preventDefault();
                        confirmation({
                        title: '',
                        content: 'Are you sure to remove products from cart ?',
                        actions: {
                        confirm: function () {
                        window.location.href = '<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart/updatePost'); ?>';
                        },
                        cancel: function () {
                        }
                        },
                        buttons: [{
                        text: $.mage.__('OK'),
                        class: 'action secondary cp-action-accept',
                        /**
                        * Click handler.
                        */
                        click: function (event) {
                        this.closeModal(event, true);
                        $('#empty_cart_button').trigger('click');
                        }
                        },
                        {
                        text: $.mage.__('Cancel'),
                        class: 'action secondary action-dismiss',
                        /**
                        * Click handler.
                        */
                        click: function (event) {
                        this.closeModal(event);
                        }
                        }
                        ]
                        });
                        });
                        });
                        });
                        </script>


                        Output will be like this :-



                        enter image description here






                        share|improve this answer


























                          0














                          Checkout Cart Page >> Clear Shopping Cart button should have alert to the users if they want to clear or not.



                          Here I am overriding form.phtml in my theme.



                          app/design/frontend/Namespace/yourthemename/Magento_Checkout/templates/cart/form.phtml




                          form.phtml





                          <?php
                          /**
                          * Copyright © Magento, Inc. All rights reserved.
                          * See COPYING.txt for license details.
                          */

                          // @codingStandardsIgnoreFile

                          /** @var $block MagentoCheckoutBlockCartGrid */
                          ?>
                          <?php $mergedCells = ($this->helper('MagentoTaxHelperData')->displayCartBothPrices() ? 2 : 1); ?>
                          <?= $block->getChildHtml('form_before') ?>
                          <form action="<?= /* @escapeNotVerified */ $block->getUrl('checkout/cart/updatePost') ?>"
                          method="post"
                          id="form-validate"
                          data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
                          {"validationURL" : "/checkout/cart/updateItemQty"}
                          }'
                          class="form form-cart">
                          <?= $block->getBlockHtml('formkey') ?>
                          <div class="cart table-wrapper<?= $mergedCells == 2 ? ' detailed' : '' ?>">
                          <?php if ($block->getPagerHtml()): ?>
                          <div class="cart-products-toolbar cart-products-toolbar-top toolbar" data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?></div>
                          <?php endif ?>
                          <table id="shopping-cart-table"
                          class="cart items data table"
                          data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
                          "updateCartActionContainer": "#update_cart_action_container"}}'>
                          <caption role="heading" aria-level="2" class="table-caption"><?= /* @escapeNotVerified */ __('Shopping Cart Items') ?></caption>
                          <thead>
                          <tr>
                          <th class="col item" scope="col"><span><?= /* @escapeNotVerified */ __('Item') ?></span></th>
                          <th class="col price" scope="col"><span><?= /* @escapeNotVerified */ __('Price') ?></span></th>
                          <th class="col qty" scope="col"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
                          <th class="col subtotal" scope="col"><span><?= /* @escapeNotVerified */ __('Subtotal') ?></span></th>
                          </tr>
                          </thead>
                          <?php foreach ($block->getItems() as $_item): ?>
                          <?= $block->getItemHtml($_item) ?>
                          <?php endforeach ?>
                          </table>
                          <?php if ($block->getPagerHtml()): ?>
                          <div class="cart-products-toolbar cart-products-toolbar-bottom toolbar" data-attribute="cart-products-toolbar-bottom"><?= $block->getPagerHtml() ?></div>
                          <?php endif ?>
                          </div>
                          <div class="cart main actions">
                          <?php if ($block->getContinueShoppingUrl()): ?>
                          <a class="action continue"
                          href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>"
                          title="<?= $block->escapeHtml(__('Continue Shopping')) ?>">
                          <span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span>
                          </a>
                          <?php endif; ?>
                          <button type="button"
                          title="<?php echo $block->escapeHtml(__('Clear Shopping Cart')); ?>"
                          class="action clear" id="cp-empty_cart_button">
                          <span><?php /* @escapeNotVerified */
                          echo __('Clear Shopping Cart'); ?></span>
                          </button>
                          <button type="submit"
                          name="update_cart_action"
                          data-cart-empty=""
                          value="empty_cart"
                          title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
                          class="action clear" id="empty_cart_button" style="display: none;">
                          <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
                          </button>
                          <button type="submit"
                          name="update_cart_action"
                          data-cart-item-update=""
                          value="update_qty"
                          title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
                          class="action update">
                          <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
                          </button>
                          <input type="hidden" value="" id="update_cart_action_container" data-cart-item-update=""/>
                          </div>
                          </form>
                          <?= $block->getChildHtml('checkout.cart.order.actions') ?>
                          <?= $block->getChildHtml('shopping.cart.table.after') ?>
                          <script type="text/javascript">
                          require([
                          'jquery',
                          'Magento_Ui/js/modal/alert',
                          'Magento_Ui/js/modal/confirm'
                          ], function ($, alertt, confirmation) {
                          $(document).ready(function () {
                          $('.cp-action-accept').parents('aside').addClass('confirm');
                          $('#cp-empty_cart_button').on('click', function (event) {
                          event.preventDefault();
                          confirmation({
                          title: '',
                          content: 'Are you sure to remove products from cart ?',
                          actions: {
                          confirm: function () {
                          window.location.href = '<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart/updatePost'); ?>';
                          },
                          cancel: function () {
                          }
                          },
                          buttons: [{
                          text: $.mage.__('OK'),
                          class: 'action secondary cp-action-accept',
                          /**
                          * Click handler.
                          */
                          click: function (event) {
                          this.closeModal(event, true);
                          $('#empty_cart_button').trigger('click');
                          }
                          },
                          {
                          text: $.mage.__('Cancel'),
                          class: 'action secondary action-dismiss',
                          /**
                          * Click handler.
                          */
                          click: function (event) {
                          this.closeModal(event);
                          }
                          }
                          ]
                          });
                          });
                          });
                          });
                          </script>


                          Output will be like this :-



                          enter image description here






                          share|improve this answer
























                            0












                            0








                            0






                            Checkout Cart Page >> Clear Shopping Cart button should have alert to the users if they want to clear or not.



                            Here I am overriding form.phtml in my theme.



                            app/design/frontend/Namespace/yourthemename/Magento_Checkout/templates/cart/form.phtml




                            form.phtml





                            <?php
                            /**
                            * Copyright © Magento, Inc. All rights reserved.
                            * See COPYING.txt for license details.
                            */

                            // @codingStandardsIgnoreFile

                            /** @var $block MagentoCheckoutBlockCartGrid */
                            ?>
                            <?php $mergedCells = ($this->helper('MagentoTaxHelperData')->displayCartBothPrices() ? 2 : 1); ?>
                            <?= $block->getChildHtml('form_before') ?>
                            <form action="<?= /* @escapeNotVerified */ $block->getUrl('checkout/cart/updatePost') ?>"
                            method="post"
                            id="form-validate"
                            data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
                            {"validationURL" : "/checkout/cart/updateItemQty"}
                            }'
                            class="form form-cart">
                            <?= $block->getBlockHtml('formkey') ?>
                            <div class="cart table-wrapper<?= $mergedCells == 2 ? ' detailed' : '' ?>">
                            <?php if ($block->getPagerHtml()): ?>
                            <div class="cart-products-toolbar cart-products-toolbar-top toolbar" data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?></div>
                            <?php endif ?>
                            <table id="shopping-cart-table"
                            class="cart items data table"
                            data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
                            "updateCartActionContainer": "#update_cart_action_container"}}'>
                            <caption role="heading" aria-level="2" class="table-caption"><?= /* @escapeNotVerified */ __('Shopping Cart Items') ?></caption>
                            <thead>
                            <tr>
                            <th class="col item" scope="col"><span><?= /* @escapeNotVerified */ __('Item') ?></span></th>
                            <th class="col price" scope="col"><span><?= /* @escapeNotVerified */ __('Price') ?></span></th>
                            <th class="col qty" scope="col"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
                            <th class="col subtotal" scope="col"><span><?= /* @escapeNotVerified */ __('Subtotal') ?></span></th>
                            </tr>
                            </thead>
                            <?php foreach ($block->getItems() as $_item): ?>
                            <?= $block->getItemHtml($_item) ?>
                            <?php endforeach ?>
                            </table>
                            <?php if ($block->getPagerHtml()): ?>
                            <div class="cart-products-toolbar cart-products-toolbar-bottom toolbar" data-attribute="cart-products-toolbar-bottom"><?= $block->getPagerHtml() ?></div>
                            <?php endif ?>
                            </div>
                            <div class="cart main actions">
                            <?php if ($block->getContinueShoppingUrl()): ?>
                            <a class="action continue"
                            href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>"
                            title="<?= $block->escapeHtml(__('Continue Shopping')) ?>">
                            <span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span>
                            </a>
                            <?php endif; ?>
                            <button type="button"
                            title="<?php echo $block->escapeHtml(__('Clear Shopping Cart')); ?>"
                            class="action clear" id="cp-empty_cart_button">
                            <span><?php /* @escapeNotVerified */
                            echo __('Clear Shopping Cart'); ?></span>
                            </button>
                            <button type="submit"
                            name="update_cart_action"
                            data-cart-empty=""
                            value="empty_cart"
                            title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
                            class="action clear" id="empty_cart_button" style="display: none;">
                            <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
                            </button>
                            <button type="submit"
                            name="update_cart_action"
                            data-cart-item-update=""
                            value="update_qty"
                            title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
                            class="action update">
                            <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
                            </button>
                            <input type="hidden" value="" id="update_cart_action_container" data-cart-item-update=""/>
                            </div>
                            </form>
                            <?= $block->getChildHtml('checkout.cart.order.actions') ?>
                            <?= $block->getChildHtml('shopping.cart.table.after') ?>
                            <script type="text/javascript">
                            require([
                            'jquery',
                            'Magento_Ui/js/modal/alert',
                            'Magento_Ui/js/modal/confirm'
                            ], function ($, alertt, confirmation) {
                            $(document).ready(function () {
                            $('.cp-action-accept').parents('aside').addClass('confirm');
                            $('#cp-empty_cart_button').on('click', function (event) {
                            event.preventDefault();
                            confirmation({
                            title: '',
                            content: 'Are you sure to remove products from cart ?',
                            actions: {
                            confirm: function () {
                            window.location.href = '<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart/updatePost'); ?>';
                            },
                            cancel: function () {
                            }
                            },
                            buttons: [{
                            text: $.mage.__('OK'),
                            class: 'action secondary cp-action-accept',
                            /**
                            * Click handler.
                            */
                            click: function (event) {
                            this.closeModal(event, true);
                            $('#empty_cart_button').trigger('click');
                            }
                            },
                            {
                            text: $.mage.__('Cancel'),
                            class: 'action secondary action-dismiss',
                            /**
                            * Click handler.
                            */
                            click: function (event) {
                            this.closeModal(event);
                            }
                            }
                            ]
                            });
                            });
                            });
                            });
                            </script>


                            Output will be like this :-



                            enter image description here






                            share|improve this answer












                            Checkout Cart Page >> Clear Shopping Cart button should have alert to the users if they want to clear or not.



                            Here I am overriding form.phtml in my theme.



                            app/design/frontend/Namespace/yourthemename/Magento_Checkout/templates/cart/form.phtml




                            form.phtml





                            <?php
                            /**
                            * Copyright © Magento, Inc. All rights reserved.
                            * See COPYING.txt for license details.
                            */

                            // @codingStandardsIgnoreFile

                            /** @var $block MagentoCheckoutBlockCartGrid */
                            ?>
                            <?php $mergedCells = ($this->helper('MagentoTaxHelperData')->displayCartBothPrices() ? 2 : 1); ?>
                            <?= $block->getChildHtml('form_before') ?>
                            <form action="<?= /* @escapeNotVerified */ $block->getUrl('checkout/cart/updatePost') ?>"
                            method="post"
                            id="form-validate"
                            data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
                            {"validationURL" : "/checkout/cart/updateItemQty"}
                            }'
                            class="form form-cart">
                            <?= $block->getBlockHtml('formkey') ?>
                            <div class="cart table-wrapper<?= $mergedCells == 2 ? ' detailed' : '' ?>">
                            <?php if ($block->getPagerHtml()): ?>
                            <div class="cart-products-toolbar cart-products-toolbar-top toolbar" data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?></div>
                            <?php endif ?>
                            <table id="shopping-cart-table"
                            class="cart items data table"
                            data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
                            "updateCartActionContainer": "#update_cart_action_container"}}'>
                            <caption role="heading" aria-level="2" class="table-caption"><?= /* @escapeNotVerified */ __('Shopping Cart Items') ?></caption>
                            <thead>
                            <tr>
                            <th class="col item" scope="col"><span><?= /* @escapeNotVerified */ __('Item') ?></span></th>
                            <th class="col price" scope="col"><span><?= /* @escapeNotVerified */ __('Price') ?></span></th>
                            <th class="col qty" scope="col"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
                            <th class="col subtotal" scope="col"><span><?= /* @escapeNotVerified */ __('Subtotal') ?></span></th>
                            </tr>
                            </thead>
                            <?php foreach ($block->getItems() as $_item): ?>
                            <?= $block->getItemHtml($_item) ?>
                            <?php endforeach ?>
                            </table>
                            <?php if ($block->getPagerHtml()): ?>
                            <div class="cart-products-toolbar cart-products-toolbar-bottom toolbar" data-attribute="cart-products-toolbar-bottom"><?= $block->getPagerHtml() ?></div>
                            <?php endif ?>
                            </div>
                            <div class="cart main actions">
                            <?php if ($block->getContinueShoppingUrl()): ?>
                            <a class="action continue"
                            href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>"
                            title="<?= $block->escapeHtml(__('Continue Shopping')) ?>">
                            <span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span>
                            </a>
                            <?php endif; ?>
                            <button type="button"
                            title="<?php echo $block->escapeHtml(__('Clear Shopping Cart')); ?>"
                            class="action clear" id="cp-empty_cart_button">
                            <span><?php /* @escapeNotVerified */
                            echo __('Clear Shopping Cart'); ?></span>
                            </button>
                            <button type="submit"
                            name="update_cart_action"
                            data-cart-empty=""
                            value="empty_cart"
                            title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
                            class="action clear" id="empty_cart_button" style="display: none;">
                            <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
                            </button>
                            <button type="submit"
                            name="update_cart_action"
                            data-cart-item-update=""
                            value="update_qty"
                            title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
                            class="action update">
                            <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
                            </button>
                            <input type="hidden" value="" id="update_cart_action_container" data-cart-item-update=""/>
                            </div>
                            </form>
                            <?= $block->getChildHtml('checkout.cart.order.actions') ?>
                            <?= $block->getChildHtml('shopping.cart.table.after') ?>
                            <script type="text/javascript">
                            require([
                            'jquery',
                            'Magento_Ui/js/modal/alert',
                            'Magento_Ui/js/modal/confirm'
                            ], function ($, alertt, confirmation) {
                            $(document).ready(function () {
                            $('.cp-action-accept').parents('aside').addClass('confirm');
                            $('#cp-empty_cart_button').on('click', function (event) {
                            event.preventDefault();
                            confirmation({
                            title: '',
                            content: 'Are you sure to remove products from cart ?',
                            actions: {
                            confirm: function () {
                            window.location.href = '<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart/updatePost'); ?>';
                            },
                            cancel: function () {
                            }
                            },
                            buttons: [{
                            text: $.mage.__('OK'),
                            class: 'action secondary cp-action-accept',
                            /**
                            * Click handler.
                            */
                            click: function (event) {
                            this.closeModal(event, true);
                            $('#empty_cart_button').trigger('click');
                            }
                            },
                            {
                            text: $.mage.__('Cancel'),
                            class: 'action secondary action-dismiss',
                            /**
                            * Click handler.
                            */
                            click: function (event) {
                            this.closeModal(event);
                            }
                            }
                            ]
                            });
                            });
                            });
                            });
                            </script>


                            Output will be like this :-



                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            Manish Goswami

                            502314




                            502314






























                                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.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • 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%2f244815%2fshopping-cart-is-not-clearing-on-the-cart-page%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

                                1300-talet

                                1300-talet

                                Display a custom attribute below product name in the front-end Magento 1.9.3.8