How to add custom shipping price when create order programatically in Magento

How to add custom shipping price when create order programatically in Magento

Step 1: Add below code in custom order create function.

$shippingPrice = 20;
Mage::register('shipping_cost', $shippingPrice);

Step 2: Now open file app\code\core\Mage\Shipping\Model\Carrier\Flatrate.php
and add the code below.

Find code::
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);

And replace with::
if(Mage::registry('shipping_cost'))
{
$method->setPrice(Mage::registry('shipping_cost'));
$method->setCost(Mage::registry('shipping_cost'));
} else {
$method->setPrice('0.00');
$method->setCost('0.00');
}

Step 3: Done. Clear the cache.

Note: Override the file app\code\core\Mage\Shipping\Model\Carrier\Flatrate.php in local like : app\code\local\Mage\Shipping\Model\Carrier\Flatrate.php ... as you know :)
How to add custom shipping price when create order programatically in Magento How to add custom shipping price when create order programatically in Magento Reviewed by Web Technology Funda on 11:30:00 PM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!