Magento 2 How to get Customer Shipping Address Street Line 2 details

To get Customer address street second line details from magento 2 we need to split the data as the

data is present in the form of an array, so you can store values in the variable and split the value of


the array to get the customer street address details , the below code logic might help you to get the details




    $orderId = 1;


    
     $orderDetailsArray = $objectManager->create('Magento\Sales\Model\Order')->load($orderId);


     
      $shippingDetailsData =$orderDetailsArray->getShippingAddress();



$customerStreet = $shippingDetailsData->getStreet();



#get customer shipping street



#get order details shipping address line 1
print_r($customerStreet[0]);




#get order details shipping address line 2
        print_r($customerStreet[1]);




Explanation for the above code is given below , first we are loading the order object . For the order object

we will pass the order id of the order increment id , the following order id loads the data from the database

tables, when the data is loaded we will try to get the shipping details of the customer from the order details

by using the following method $orderDetailsArray->getShippingAddress();  

The shipping address loads the complete shipping information of the order, when you try to get the 

street details from the shippingAddress object and try to echo you will get a Notice : Array to string 

conversion in line number on your screen , this is becuase the street details is present in the form of 

the array, to get the details of the array , you will need to parse the array , so we can store it one 

variable  called as $customerStreet  , the following details can be passed by using the key of the 

array and you will be able to echo the customer street 1 and customer street line 2 from the 

address details

Comments

  1. Wonderful article, Which you have shared about the service. Your article is very important and I really enjoyed reading it.
    freight shipping miami

    ReplyDelete
  2. i found new platform thru this weblog and got to understand who i am capable of cope with burden of lot many essay writing tasks. Now i am feeling rate after segregation of my paintings over unique writers over net. Movers And Packers In Jaipur

    ReplyDelete
  3. Such a lovely collection about shipping which you have shared here. I liked your way to express your views in this post. Thank you for sharing this blog with us. shipping from China to USA

    ReplyDelete
  4. The most obvious advantage sea offers are the affordability, when it comes to choosing the modes of transportation always choose the one that suits you the most. You can hire shipping from China to UK for more information. Based on my experience the most obvious advantage that ships can carry all kinds of rather heavy goods irrespective of the distance.

    ReplyDelete
  5. I agree with your point of view of this article. we provide Air Freight Forwarders at affordable cost. to know more visit our website.

    ReplyDelete
  6. This is a smart blog. I mean it. You have an excellent knowledge about this topic. Thanks for sharing such a great blogs to us. USA to Australia Shipping

    ReplyDelete
  7. I really like this post. I've been searching finished for this! Thank heavens I discovered it on your blog . You have filled my heart with joy! Much obliged once more! Continue refreshing more amazing posts.. shipping from china to Amazon FBA

    ReplyDelete
  8. What a great post that you have shared here. You make information effortless for us that we get good facts about it. Thanks for this informative blog.Keep it up. Send Your Parcel From Usa To Kenya

    ReplyDelete
  9. After reading the information you have provided in the post I got some important knowledge from this. Thanks for sharing it. shipping from China to USA FBA

    ReplyDelete

Post a comment