0

i want to Add "add to compare" and "add to Wishlist" functionality in minicart magento 2.

I cannot find where to modify. Can you help me, please?

thanks

0

Hope you doing well.

please find this file here.

magento-directory/vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html

please override this template file and your Wishlist and Compare Functionality as Edit and delete functionality work here.

this is Block file from where magento set url and all data.

magento-directory/vendor/magento/module-checkout/Block/Cart/Sidebar.php

Please find related files here:

magento-directory/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html

magento-directory/vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js

magento-directory/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js

please properly check and do as Delete Functionality works in minicart. so you can easily achieve what you want.

magento-directory/vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html

<a href="#" data-bind="attr: {'data-cart-item': item_id, title: $t('Remove item')}"
                       class="action delete">
                        <span data-bind="i18n: 'Remove'"></span>
                    </a>

magento-directory/vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js

'url': {
         'remove': window.checkout.removeItemUrl,
       },
'button':{
         'remove': '#mini-cart a.action.delete',
        },

magento-directory/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js

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();
                        }
                    }
                });
            };

_removeItem: function (elem) {
            var itemId = elem.data('cart-item');

            this._ajax(this.options.url.remove, {
                'item_id': itemId
            }, elem, this._removeItemAfter);
        },

Thanks

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.