1
votes

I have created a catalog price rule and it is working fine when placing orders from front end. But, when I programmatically create orders through custom code, this rules were found not working eventhough I am assigning this particular order to a customer who is belongs to the provided customer group. Can anybody help on this ? Please see related code below:

....
//Setting customer group ID

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

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

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

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

Thanks! Iqbal.

1
My question in another words: "How can I apply catalog rules to a Quote object programatically ?". Thanks! - iqbalmp

1 Answers

0
votes

To apply the catalog price rule to the quote object programatically, use this

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