1
votes

I have created orders programmatically in magento and created cart rule from admin panel. Rule is if any orders subtotal is more than 200 then apply discount of 50. Now I want to check that if any cart rule is present, and if it is then check rule condition and apply rule to subtotal of order during order creation. Please help. Thanks in advance.

1
This kind of question is off topic here, but you may find it isn't on the Magento StackExchange - scrowler
I just want how to apply cart rule on subtotal of programmatically created order in magento - Ajinkya Bhalerao

1 Answers

0
votes

Cart rules are applied to quotes, not orders. Therefore, when you create orders programatically you need to create quote first, then convert it to order.

Applying sales rules to a quote programatically is simple. Just call;

$quote->collectTotals()->save();

after adding address, adding products, setting payment method to quote.