Shawkat
Shawkat

Reputation: 1

How to prevent adding same product to cart more then one time in magento

I am new in magento development. I dont want user to add any product more then once to the cart.if he/she need to change the qty of the product then he/she need to change it from mycart page but add to cart button only allow once to add product, after that when he/she clicks on add to cart button it must say "it is already added to the cart if you want to change the quantity then please go to mycart".

for example you can see www.flipkart.com.

Upvotes: 0

Views: 5070

Answers (1)

Yoshi
Yoshi

Reputation: 54649

Have a look at:

Product -> Inventory -> Maximum Qty Allowed in Shopping Cart

System -> Configuration -> Inventory -> Maximum Qty Allowed in Shopping Cart


Have a look at Customize Magento using Event/Observer.

Events you could use, are for example: checkout_cart_update_items_before and checkout_cart_product_add_after

Also I'd suggest looking atthe: /app/code/core/Mage/Checkout/Model/Cart.php for other events that might be helpful.

In this file also, you'll find code like:

$this->getCheckoutSession()->addError(
  Mage::helper('checkout')->__('Some of the requested products are unavailable.')
);

Which you could use for displaying the the error message to the customer.

Upvotes: 1

Related Questions