Skip to content

Magento mixin remove confirmation popup when deleting products from the mini cart?

I created mixin. When I comment out “confirm({})” in core sidebar.js it works as expected, but my mixin doest work. It does’t remove popup.
requirejs-config.js:

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/sidebar': {
                'Magento_Checkout/js/sidebar-mixin': true
            }
        }
    }
};

Created js/sidebar-mixin.js

define([
    'jquery',
], function ($) {
    'use strict';

    return function (widget) {
        $.widget('mage.sidebar', widget, {
            _initContent: function () {
                this._super();
                var self = this,
                    events = {};

                this.element.decorate('list', this.options.isRecursive);

                /**
                 * @param {jQuery.Event} event
                 */
                events['click ' + this.options.button.close] = function (event) {
                    event.stopPropagation();
                    $(this.options.targetElement).dropdownDialog('close');
                };
                events['click ' + this.options.button.checkout] = $.proxy(function () {
                    var cart = customerData.get('cart'),
                        customer = customerData.get('customer'),
                        element = $(this.options.button.checkout);

                    if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
                        // set URL for redirect on successful login/registration. It's postprocessed on backend.
                        $.cookie('login_redirect', this.options.url.checkout);

                        if (this.options.url.isRedirectRequired) {
                            element.prop('disabled', true);
                            location.href = this.options.url.loginUrl;
                        } else {
                            authenticationPopup.showModal();
                        }

                        return false;
                    }
                    element.prop('disabled', true);
                    location.href = this.options.url.checkout;
                }, this);

                /**
                 * @param {jQuery.Event} event
                 */
                events['click ' + this.options.button.remove] =  function (event) {
                    event.stopPropagation();
                    this._removeItem($(event.currentTarget));
                    // confirm({
                    //     content: this.options.confirmMessage,
                    //     actions: {
                    //         /** @inheritdoc */
                    //         confirm: function () {
                    //             this._removeItem($(event.currentTarget));
                    //         },
                    //
                    //         /** @inheritdoc */
                    //         always: function (e) {
                    //             e.stopImmediatePropagation();
                    //         }
                    //     }
                    // });
                };

                /**
                 * @param {jQuery.Event} event
                 */
                events['keyup ' + this.options.item.qty] = function (event) {
                    this._showItemButton($(event.target));
                };

                /**
                 * @param {jQuery.Event} event
                 */
                events['change ' + this.options.item.qty] = function (event) {
                    this._showItemButton($(event.target));
                };

                /**
                 * @param {jQuery.Event} event
                 */
                events['click ' + this.options.item.button] = function (event) {
                    event.stopPropagation();
                    this._updateItemQty($(event.currentTarget));
                };

                /**
                 * @param {jQuery.Event} event
                 */
                events['focusout ' + this.options.item.qty] = function (event) {
                    this._validateQty($(event.currentTarget));
                };

                this._on(this.element, events);
                this._calcHeight();
            },

        });
        return $.mage.sidebar;
    }
});