Magento:以编程方式将目录价格规则应用于订单

时间:2015-07-10 08:58:55

标签: php magento

我创建了一个目录定价规则,它在从前端下订单时工作正常。但是,当我通过自定义代码以编程方式创建订单时,发现此规则不起作用,尽管我将此特定订单分配给属于所提供客户组的客户。有人可以帮忙吗?请参阅以下相关代码:

....
//Setting customer group ID

     $this->_quote->setCustomerGroupId(9); 
    ...

............

//$currentProduct - product Object
//$curQuantity - Product quantity
$this->_quote->addProduct($currentProduct,new Varien_Object(array('qty'=> $curQuantity)));

.............

谢谢! 伊克巴尔。

1 个答案:

答案 0 :(得分:0)

要以编程方式将目录定价规则应用于引用对象,请使用此

Mage::getSingleton('checkout/cart')
    ->getQuote()
    ->setCouponCode(strlen($couponCode) ? $couponCode : '')
    ->collectTotals()
    ->save();