douduxia1551 2014-10-21 16:11
浏览 7
已采纳

Magento产品规则,一次添加一个产品

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.

  • 写回答

1条回答 默认 最新

  • dongshang1934 2014-10-22 00:57
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部