Magento 2 – Get Shipping and Billing Address of Customer After Order Placed

billing-addresscustomer-addressmagento2order-emailshipping-address

I am working on custom email template.

So I needed customer Billing and Shipping address in below file.

/vendor/magento/module-sales/view/frontend/templates/email/items.phtml

Can any 1 help me to get customer address of placed order.

Best Answer

You can add this piece of code in the file:

<?php /** @var $_order \Magento\Sales\Model\Order */ ?>
<?php $_order = $block->getOrder() ?>
<?php $billingAddress = $_order->getBillingAddress(); ?>
<?php $shippingAddress = $_order->getShippingAddress(); ?>

With $billingAddress now you can get address e.g:

<?php echo $billingAddress->getStreet() ?>
Related Topic