1

I have added popup it show but not clearing item from cart just reloaded on same page. Please someone look in this.

Below is the my script.

 <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) {
             $('#empty_cart_button').on('click', function (event) {


            event.preventDefault();
            confirmation({
                title: '',
                content: 'Are you sure to remove products from cart ?',
                actions: {
                    confirm: function () {
                        $('#empty_cart_button').click(function(){
                        $('#empty_cart_button').val($(this).val());
                        });
                         },
                    cancel: function () {
                    }
                },
                buttons: [{
                    text: $.mage.__('OK'),
                    class: 'action secondary cp-action-accept',
                    /**
                     * Click handler.
                     */
                    click: function (event) {

                       window.location.href = '<?php //echo $block->getUrl('checkout/cart/updatePost'); ?>';

                        this.closeModal(event, true);                            
                       // $('#empty_cart_button').trigger('click');
                        this.closeModal(event);
                    }


                },
                    {
                        text: $.mage.__('Cancel'),
                        class: 'action secondary action-dismiss',
                        /**
                         * Click handler.
                         */
                        click: function (event) {
                            this.closeModal(event);
                        }
                    }
                ]
            });
        });
    });
});
</script> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.