How to Disable Ajax Add to Cart on Product page in Magento 2

Disable Ajax Add to Cart on Product page in Magento 2

Happy New Year Readers! ūü•≥¬†Let’s make a good start of the new year with a new Magento solution! ūüďĖ

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 lose a chunk of users who could have been your potential customers?!

The default behavior of the Magento 2 “Add to Cart” button is on click, it uses an ajax to add the product to cart and keep the user on the product page.

Default Magento 2 add to cart button click behavior

 

Now, in order to boost the order process, you need to disable ajax add to cart on the product page in Magento 2 and redirect customers directly to the checkout page. This can help push your customers for the purchase and also save your customers’ time for completing the order.

Steps to Disable Ajax Add to Cart on Product Page in Magento 2:

  1. Find the following code from vendor\magento\module-catalog\view\frontend\templates\product\view\addtocart.phtml file
     
  2. Go to app/design/frontend/[Vendor]/[Theme]/Magento_Catalog/templates/product/view/addtocart.phtml and replace the below code to add the bindsubmit event:
     
  3. To Redirect customers from cart page to the checkout page cart¬†on click of add to cart button,¬†Go to Stores > Configuration > Sales > Checkout > Shopping Cart and set “After Adding a Product Redirect to Shopping Cart” to Yes.Magento 2 Redirect directly to checkout

That’s all to disable ajax add to cart on Magento 2 product page and redirect customers directly to the checkout page.

Don’t forget to comment down your issues or queries in the comment section below, I would be happy to help ūüôā

If you like the solution, don’t forget to share it with your Magento buddies!

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 10 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.