SOAP – Handling Street Address #1 & #2 in Shipping Address

shipping-addresssoap

I'm working on some Magento order export using SOAP and sales_order.info Using the shipping_address I'm able to get the obejct street. However this seem to include both Street 1 and Street 2. Which is the way of extracting both street 1st line and 2nd line, as I need to pass these values as two different fields to a separate system?

I use $shipdata['shipping_address']['street']

Best Answer

The street field contains street1 and street2 separated by a line break. In order to get one or the other just explode the string by \n.

$street = explode('\n', $street);

You can then just pull $street[0] for street1 or $street[1] for street2. Alternatively if you are accessing the customer address object you can just call street1 or street2 directly to do the same thing:

$street1 = $address->getStreet1();
$street2 = $address->getStreet2();