Magento 无法以编程方式设置折扣金额

Magento 无法以编程方式设置折扣金额,magento,Magento,我试图通过编程来创建订单。发生得非常好。我只是不知道如何通过编程设置折扣金额。对于不同的订单,这将是不同的。在将产品添加到报价中时,您可以使用以下方法向产品添加自定义价格: $custom_price = 100; //Products new price for the specific order/customer. $qty = 1; $product_id = 210; $product = Mage::getModel('catalog/product')->load($prod

我试图通过编程来创建订单。发生得非常好。我只是不知道如何通过编程设置折扣金额。对于不同的订单,这将是不同的。

在将产品添加到报价中时,您可以使用以下方法向产品添加自定义价格:

$custom_price = 100; //Products new price for the specific order/customer.
$qty = 1;
$product_id = 210;
$product = Mage::getModel('catalog/product')->load($product_id);

$quoteItem = $quote->addProduct($product, $qty);
$quoteItem->setCustomPrice($custom_price);
$quoteItem->setOriginalCustomPrice($custom_price);
$quoteItem->getProduct()->setIsSuperMode(true);
$quote->save();

给我们看看你的代码。请阅读和阅读。