How to Restrict Customer from Adding Product to Cart in Magento 2

The post shows the solution to restrict customer from adding product to cart in Magento 2.

You may use this solution when you are running an offer where conditions need to be checked for eligibility to avail discounts before the customers place an order. Till then, the admin can restrict customers to add products to the cart or update the cart.

Also, if you are accepting orders based on conditions such as only a particular customer group can place an order, or customers from specific locations can place the order, in these cases, you may restrict them to add the product to the cart until the conditions are checked.

Hence, whenever you want to confirm the order placement request from the backend and only after that allow customer to add another product or update the cart, use the below solution.

Method to Restrict Customer from Adding Product to Cart in Magento 2:

Add code in app\code\vendor\module\etc\di.xml

Create file Lockcart.php under app\code\vendor\module\Plugin\

That’s it.

Any doubts? Please mention them in the Comments section below.

Please share the solution with the Magento Community via social media.

Thank you.

5
(based on 7 Reviews)
How to Restrict Customer from Adding Product to Cart in Magento 2

Krishna Rajyaguru

Krishna is a Magento developer at Meetanshi. She is always ready to learn new things. Apart from work, she likes to read books and spend time with family.

Leave a Reply

Your email address will not be published. Required fields are marked *