1

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?

  • Have you tried with template path hint ? – Murtuza Zabuawala Dec 13 '17 at 9:11
  • @MurtuzaZabuawala The modal popup is called via a Javascript function, I don't think it will be visible in the template hints – Maarten Wolfsen Dec 13 '17 at 9:22
  • Just try once and chek – Murtuza Zabuawala Dec 13 '17 at 9:23
  • @MurtuzaZabuawala Not visible, as expected – Maarten Wolfsen Dec 13 '17 at 9:33
5

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);
            }
       }]
    });
};
  • I have added the code you recommended, emptied the static content and emptied the cache, but I can't see any difference. Any idea why it doesn't work? The current sidebar.js file: paste.ofcode.org/6hEDjhka3HsPYcSRxTVZWE – Maarten Wolfsen Dec 13 '17 at 10:46
  • I see no problem in your code. Please redeploy static content, clear browser caches and try again – Quan Le Dec 13 '17 at 11:04
  • With your help, I solved the problem by adding the code to my own JS – Maarten Wolfsen Dec 13 '17 at 11:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.