{"id":1631,"date":"2021-03-08T23:34:30","date_gmt":"2021-03-08T23:34:30","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/show-popup-after-add-to-cart-action-in-magento-2\/"},"modified":"2025-07-17T09:39:55","modified_gmt":"2025-07-17T04:09:55","slug":"show-popup-after-add-to-cart-action-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/show-popup-after-add-to-cart-action-in-magento-2\/","title":{"rendered":"How to Show Popup After &#8220;Add to cart&#8221; Action in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A good customer experience impacts brand loyalty and customer retention. A merchant can make the customers\u2019 purchase process easier and enhance the on-site experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A good customer experience is always more persuasive than any good advertisement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hence, I have come up with one such solution to&nbsp;show popup after \u201cadd to cart\u201d action in Magento 2&nbsp;that will make it easy for the customers to proceed to checkout and speed up the conversion process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the default\u00a0Magento 2\u00a0store, the customer only gets a small notice that says \u201cYou added Product to your shopping cart.\u201d at the top or bottom of the page when he\/she clicks on the add to cart button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of that, offer your customers an immediate visual verification without having to scroll up or down by showing a popup when they add a product to the cart.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An added benefit is that the popup enhances your store\u2019s design and layout!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hence, show popup on \u201cadd to cart\u201d action in your store using the method shown here:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Show Popup After \u201cAdd to cart\u201d Action in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Copy&nbsp;<strong>catalog-add-to-cart.js<\/strong>&nbsp;to your theme from<br><strong>vendor\/magento\/module-catalog\/view\/frontend\/web\/js\/catalog-add-to-cart.js&nbsp;<\/strong>to&nbsp;<strong>app\/design\/frontend\/Theme\/ThemeName\/Magento_Catalog\/web\/js\/catalog-add-to-cart.js<br><\/strong>or override&nbsp;<strong>catalog-add-to-cart.js&nbsp;<\/strong>to your custom module.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>requirejs-config.js<\/strong>&nbsp;file in&nbsp;<strong><strong>app\\code\\Vendor\\Module\\view\\frontend<\/strong><\/strong> and use the below code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var config =\n    {\n        map:\n        {\n           '*':\n               {\n                'Magento_Catalog\/js\/catalog-add-to-cart': 'Vendor_Module\/js\/catalog-add-to-cart'\n               }\n        }\n    };<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Find&nbsp;<strong>ajaxSubmit:<\/strong>&nbsp;function and add below code after&nbsp;<strong><strong>self.enableAddToCartButton(form);<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/popup modal code\nvar popup = $('&lt;div class=\"add-to-cart-modal-popup\"\/>').html($('.page-title span').text() + '&lt;span> has been added to cart.&lt;\/span>').modal({\n    modalClass: 'add-to-cart-popup',\n    title: $.mage.__(\"Popup Title\"),\n    buttons: [\n        {\n            text: 'Continue Shopping',\n            click: function () {\n                this.closeModal();\n            }\n        },\n        {\n            text: 'Proceed to Checkout',\n            click: function () {\n                window.location = window.checkout.checkoutUrl\n            }\n        }\n    ]\n});\npopup.modal('openModal');<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pass a popup title as per your requirement.<br>The popup with \u201cContinue Shopping\u201d and \u201cProceed to Checkout\u201d button will display like the below image:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/Screenshot-at-February-26th-2021-5.56.13-pm-1024x383.png\" alt=\"Blog output popup\" class=\"wp-image-13617\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Offer your customers a clear overview of the products they have added to the cart by using this method!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A good customer experience impacts brand loyalty and customer retention. A merchant can make the customers\u2019 purchase process easier and enhance the on-site experience. A&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1631","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1631"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1631\/revisions"}],"predecessor-version":[{"id":18183,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1631\/revisions\/18183"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}