I have one restricted product, here how to do selected single product should be purchased alone? No other products are eligible to add add-to-cart if this product available in the add-to-cart, same if other products available in add-to-cart this product not eligible to add add-to-cart. How to achieve this in Magento?
Hi @Aveeva,
You can do it using event observer in magento.
You can use "checkout_cart_product_add_before" event and in observer you can check your current product is already exist or not in quote. Then you restrict as per your conditions.
create-checkout_cart_product_add_before-observer-magento
To get Quote in observer.
$quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item) { $productId = $item->getProductId(); // Do something more }
I hope it will help you.
@Vimal Kumar I am new to magento, where i can add above code?
Hi @Aveeva
I have a download custom module from below url.
Module Download
You need to make change in :
app/code/local/VP/CartOverride/Model/Observer.php
@Vimal Kumar What i need to change in,