Programmatically add product to cart with price change

前端 未结 6 1336
孤街浪徒
孤街浪徒 2020-11-28 20:44

I want to add a product to cart programmatically. Also, I want to change the product price when added to cart.

Suppose, my product\'s price is $100. I wanted to cha

6条回答
  •  难免孤独
    2020-11-28 20:48

    It is possible to set a customer specific price of a quote item. Hence, something like this should do it:

    $quoteItem = $quote->addProduct($product, $qty);
    $quoteItem->setCustomPrice($price);
    // we need this since Magento 1.4
    $quoteItem->setOriginalCustomPrice($price);
    $quote->save();
    

    Hope this helps...

提交回复
热议问题