Hello Magento Friends,

Hope all are healthy, wealthy, and safe. Today I am going to throw light on How to Prevent Adding Same Product to Cart more than One time in Magento 2.

Many times it may happen that the user actually needs a single quantity but mistakenly adds the same product more than once to the cart. This leads to unnecessary product buying. To avoid this, Magento 2 store owners can prevent customers to add the same product to the cart more than one time. If the user needs an additional quantity, he/she needs to go to My Cart and change the quantity of the product accordingly.

If the user tries to add the already added product to the cart, it shows the message, “Item already in cart. If you need to change quantity please go to my cart.”

Let’s find out the steps, How to Prevent Adding Same Product to Cart more than One time in Magento 2.

Steps to Prevent Adding Same Product to Cart more than One time in Magento 2:

Step 1: First, go to the below path

app\code\Vendor\Extension\etc\di.xml

And add the code as follows

Step 2: Now, move to the below path

app\code\Vendor\Extension\Plugin\Magento\Checkout\Cart\BeforeAddToCart.php

And add the below-mentioned code

Conclusion:

Hence, with the above steps, you can Prevent Adding Same Product to Cart more than One time in Magento 2. Alternatively, you can even restrict your customer from adding the product to the cart in Magento 2.

Mention in the comment part, your difficulties, and queries. Do share the article with your Magento buddies. Stay connected, stay updated with the latest Magento news and solutions.

Happy Coding!

Click to rate this post!
[Total: 6 Average: 5]