cancel
Showing results for 
Search instead for 
Did you mean: 

How to do selected single product should be purchase alone?

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

How to do selected single product should be purchase alone?

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?

4 REPLIES 4

Re: How to do selected single product should be purchase alone?

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.

Re: How to do selected single product should be purchase alone?

@Vimal Kumar I am new to magento, where i can add above code?

Re: How to do selected single product should be purchase alone?

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

 

Re: How to do selected single product should be purchase alone?

@Vimal Kumar  What i need to change in,

 

app/code/local/VP/CartOverride/Model/Observer.php
 
<?php
class VP_CartOverride_Model_Observer
{

            public function checkCart(Varien_Event_Observer $observer)
            {
                //Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
                //$user = $observer->getEvent()->getUser();
                //$user->doSomething();
            }
        
}