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');
  • is order address already exits? – Amit Bera Sep 8 '14 at 9:49
  • yes, the order already exits. – aceveve Sep 8 '14 at 10:00
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();

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.