3

I need to get a second line of Magento order shipping address, currently I am getting information like so:

        $this->formatText($order->getBillingAddress()->getData('prefix')),
        $this->formatText($order->getBillingAddress()->getData('firstname')),
        $this->formatText($order->getBillingAddress()->getData('middlename')),
        $this->formatText($order->getBillingAddress()->getData('lastname')),
        $this->formatText($order->getBillingAddress()->getData('suffix')),
        $this->formatText($order->getBillingAddress()->getData('street')),
        $this->formatText($order->getBillingAddress()->getData('city')),
        $this->formatText($order->getBillingAddress()->getData('region')),
        $this->formatText($order->getBillingAddress()->getData('country_id')),

All is good, however when customer supplies address line 2, see image below:

enter image description here

My code does not capture that line, anyone knows how to get address line 2 in Magento?

2 Answers 2

6

You can get the street line like below :

$order->getBillingAddress()->getStreet(1);
$order->getBillingAddress()->getStreet(2);
0
1

Tried repairing it through proper configuration?

System Config -> Customers -> Customer Configuration -> Name and Address Options

Change Number of Lines in a Street Address

Unless your template is bolloxed up, it checks this config to know how many address lines to include in the templates and database.

2
  • Thanks for suggestion @Khushbu_sipl, in my configuration, I have set up Magento to record 2 lines. And thanks to Manashvi birla answer above, I am now able to retrieve the second line. All good :)
    – K.I
    Commented Mar 14, 2017 at 11:35
  • 1
    okay :) good luck Commented Mar 14, 2017 at 11:38

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.