Search code examples
phpxmlmagentoshopping-cartmagento-rules

Magento Product Rules, adding one product at a time


I sell two services in my Magento store. I've disabled cart and multi-page checkout. I want to sell only one service at a time. Means I want to accomplish, if customer tries to add both services to cart so the previous service should be removed.

How can I accomplish this? I've been searching this from last 5 hours.


Solution

  • in the file

    app/code/core/Mage/Sales/Model/Quote.php
    

    there is a method public function addProduct($product, $request = null); you should only add $this->removeAllItems(); to be the first line in the method, like:

    public function addProduct(Mage_Catalog_Model_Product $product, $request = null)
    {
        $this->removeAllItems(); // new code
        ....
    }
    

    of course, it's better idea to be overridden in the local pool.