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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityYou 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() ?>
Solved my problem by following edit in below file:
/vendor/magento/module-sales/view/frontend/templates/email/items.phtml
$_order = $block->getOrder(); // get order details
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$formatedAddress = $objectManager->get('\Magento\Sales\Model\Order\Email\Sender\OrderSender');
print_r($formatedAddress->getFormattedBillingAddress($_order));
print_r($formatedAddress->getFormattedShippingAddress($_order));
getFormattedShippingAddress
is protected method you cannot access outside.
Jun 14, 2018 at 12:49
$formatedAddress = $objectManager->get('\Magento\Sales\Model\Order\Address\Renderer'); echo $formatedAddress->format($_order->getShippingAddress(), 'html')
Jun 14, 2018 at 12:52