2

I know we can get formated customer addresses by calling,

$data = $customer->getPrimaryBillingAddress()->getFormated();

Is there a similar way to get shipping address and billing address of a order as a string?

This gives me a error

$order->getBillingAddress()->getData()->getFormated()
  • Oops silly mistake. getData was the problem – Dan Jan 13 '16 at 8:48
6
$billing = $order->getBillingAddress()->getFormated();
$shipping = $order->getShippingAddress()->getFormated();

getFormated supports an optional parameter that can be html or text.

  • What I want is formated order shipping address. Not customer shipping address – Dan Jan 13 '16 at 8:45
  • 1
    @Dan. Sorry, I should read more carefully. I edited the answer. – Marius Jan 13 '16 at 8:49
  • 1
    Hey guys, great question and answers, however I have a slight problem, what if address line 2 is supplied, how do I get that? – K.I Mar 14 '17 at 10:45
  • getFormated() is returning null inside Observer, using $order = $observer->getOrder(). Any idea why? – Braza Aug 23 '18 at 15:55

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.