Question

When I remove an item in the Minicart, a modal popup pops up. This popup has two buttons: Cancel and OK. I want to change these strings to No and Yes, but I can't find the code where the modal is triggered.

I also don't want to translate Cancel and OK to No and Yes for obvious reasons. Where can I find the source for this?

Was it helpful?

Solution

Two buttons Cancel and OK is default values defined in vendor/magento/module-ui/view/base/web/js/modal/confirm.js.

If you want to update these button (not use translate), you have to override vendor/magento/module-checkout/view/frontend/web/js/sidebar.js, where confirm.js is used, by copy it to custom theme app/design/frontend/<Vendor>/<Theme>/Magento_Checkout/web/js/sidebar.js. Then change event binding for removing items like this

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

            /** @inheritdoc */
            always: function (e) {
               e.stopImmediatePropagation();
            }
        },
        buttons: [{
            text: $.mage.__('No'),
            class: 'action-secondary action-dismiss',

            /**
             * Click handler.
             */
            click: function (event) {
                this.closeModal(event);
            }
        }, {
            text: $.mage.__('Yes'),
            class: 'action-primary action-accept',

            /**
             * Click handler.
             */
            click: function (event) {
                this.closeModal(event, true);
            }
       }]
    });
};
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top