2

How can i change shipping and billing adress from order programmatically? I tried this but don't work.

$shippingAddress = Mage::getModel('sales/order_address')
->setFirstname("value")
->setMiddlename("value")
->setLastname("value")
->setSuffix("value")
->setCompany("value")
->setStreet("value"))
->setCity("value")
->setCountry_id("value")
->setRegion("value")
->setRegion_id("value")
->setPostcode("value")
->setTelephone("value")
->setFax("value");

and

$order->setShippingAddress($shippingAddress)
->setShipping_method('flatrate_flatrate');
2
  • is order address already exits?
    – Amit Bera
    Commented Sep 8, 2014 at 9:49
  • yes, the order already exits.
    – aceveve
    Commented Sep 8, 2014 at 10:00

1 Answer 1

5

if you want update shipping address of an order then you need load order then load it address object:

Step1:Order load by orded id

$order = Mage::getModel('sales/order')->load($orderId);

Step2:Get shipping address Id.

$order->getShippingAddress()->getId();

Step3:Then reset shipping address object:

$shippingAddress = Mage::getModel('sales/order_address')->load($order->getShippingAddress()->getId());

$shippingAddress
->setFirstname("value")
->setMiddlename("value")
->setLastname("value")
->setSuffix("value")
->setCompany("value")
->setStreet("value"))
->setCity("value")
->setCountry_id("value")
->setRegion("value")
->setRegion_id("value")
->setPostcode("value")
->setTelephone("value")
->setFax("value")->save();
0

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.