I am importing orders from a 3rd party application, and I need to be able to set a custom shipping amount, ignoring everything in Magento.

Here's what I tried, without success:

$quote           = Mage::getModel('sales/quote')->setStoreId($storeId);
$shippingAddress = $quote->getShippingAddress();

    ->addData($addressDetails['shipping']) // shipping data I need to save - city, region, etc

$shippingAmount = mt_rand(0, 20); // value doesn't matter

// basically everything I found related to the price in the shipping address
$shippingAddress->setTotalAmount('subtotal', $shippingAmount);
$shippingAddress->setData('shipping_incl_tax', $shippingAmount);
$shippingAddress->setData('base_shipping_incl_tax', $shippingAmount);
$shippingAddress->setData('shipping_taxable', $shippingAmount);
$shippingAddress->setData('base_shipping_taxable', $shippingAmount);
$shippingAddress->setData('shipping_amount_for_discount', $shippingAmount);
$shippingAddress->setData('base_shipping_amount_for_discount', $shippingAmount);

// maybe the rates have something to do with this ... 
foreach ($shippingAddress->getShippingRatesCollection() as $rate) {

Regardless of the value of the shipping amount I want to set, the Magento calculated value is used.

What am I missing ?


You can try this:

I imagine that you create orders programmatically:

Set Shipping cost order

This way allow you to set price of shipping to any value.


You can update shipping cost through these line of code:-

$order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
$shippingprice = 30;//custom shipping price
$order->setGrandTotal($order->getGrandTotal() + $shippingprice); //adding shipping price to grand total

It will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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