0

How to skip applying price rules while creating an order programmatically?

Code looks like this (shortened)

/** @var $quote Mage_Sales_Model_Quote */
$quote = Mage::getModel('sales/quote')
         ->setStoreId(Mage::app()->getStore('default')->getId());
$quote->assignCustomer($customer);
$quote->addProduct($product, new Varien_Object(['qty' => 1]));
$quote->getBillingAddress()->addData([..]);
$quote->getShippingAddress()->addData([..]);
$shippingAddress->setCollectShippingRates(true)
            ->collectShippingRates()
            ->setShippingMethod('my_own_shipping_module')
            ->setPaymentMethod('payment_method');

$quote->getPayment()->importData(array('method' => 'payment_method'));

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

Skipping collectTotals() didn't help.

1
  • Try to set shipping methods as flatrate_flatrate
    – sandip
    Commented May 21, 2017 at 23:55

1 Answer 1

1

@method Mage_Sales_Model_Quote_Address_Item setNoDiscount(int $value)

foreach ($quote->getAllVisibleItems() as $item) {
        $item->setNoDiscount(1);
}

Place this before

$quote->collectTotals();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.