{"id":745,"date":"2020-01-02T10:07:52","date_gmt":"2020-01-02T10:07:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/01\/02\/disable-ajax-add-to-cart-on-product-page-magento-2\/"},"modified":"2025-05-21T17:56:55","modified_gmt":"2025-05-21T12:26:55","slug":"disable-ajax-add-to-cart-on-product-page-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/disable-ajax-add-to-cart-on-product-page-magento-2\/","title":{"rendered":"How to Disable Ajax Add to Cart on Product page in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Do your large number of customers abandon cart due to lengthy checkout process? Do you want to optimize the checkout process so that you never&nbsp;lose a chunk of users who could have been your potential customers?!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default behavior of the Magento 2 &#8220;Add to Cart&#8221; button is on click, it uses an ajax to add the product to cart and keep the user on the product page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/01\/Ajax-add-to-cart-700x501.gif\" alt=\"Ajax Add to Cart\" class=\"wp-image-30143\" style=\"width:495px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, in order to boost the order process, you need to <strong>disable ajax add to cart on the product page in Magento 2<\/strong> and redirect customers directly to the checkout page. This can help push your customers for the purchase and also save your&nbsp;customers\u2019 time for completing the order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Disable Ajax Add to Cart on Product Page in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Find the following code from <strong><strong>vendor\\magento\\module-catalog\\view\\frontend\\templates\\product\\view\\addtocart.phtml<\/strong><\/strong> file<\/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=\"\">&lt;script type=\"text\/x-magento-init\">\n    {\n        \"#product_addtocart_form\": {\n            \"Magento_Catalog\/product\/view\/validation\": {\n                \"radioCheckboxClosest\": \".nested\"\n            }\n        }\n    }\n&lt;\/script><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Go to <strong>app\/design\/frontend\/[Vendor]\/[Theme]\/Magento_Catalog\/templates\/product\/view\/addtocart.phtml <\/strong>and&nbsp;replace the below code to add the<strong>&nbsp;bindsubmit&nbsp;<\/strong>event:<\/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=\"\">&lt;script type=\"text\/x-magento-init\">\n   {\n    \"#product_addtocart_form\": {\n        \"Magento_Catalog\/product\/view\/validation\": {\n            \"bindSubmit\": true,\n            \"radioCheckboxClosest\": \".nested\"\n        }\n    }\n   }\n&lt;\/script><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. To Redirect customers from cart page to the checkout page cart&nbsp;on click of add to cart button,&nbsp;Go to&nbsp;<strong>Stores &gt; Configuration &gt; Sales &gt; Checkout &gt; Shopping Cart<\/strong>&nbsp;and set \u201c<strong>After Adding a Product Redirect to Shopping Cart<\/strong>\u201d to&nbsp;<strong>Yes<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/12\/Redirect-directly-to-checkout.png\" alt=\"Magento 2 Redirect directly to checkout\" class=\"wp-image-7236\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all to disable ajax add to cart on Magento 2 product page and redirect customers directly to the checkout page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you like the solution, don\u2019t forget to share it with your Magento buddies!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do your large number of customers abandon cart due to lengthy checkout process? Do you want to optimize the checkout process so that you never&nbsp;lose&#8230;<\/p>\n","protected":false},"author":5,"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-745","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/745","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=745"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"predecessor-version":[{"id":14010,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions\/14010"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}