I use Magento 2.3 If I want to access in view order page (on my account) shipping address, the result is null.

$orderId  = $block->getOrderId();
$orderData = $block->getOrderDetails($orderId);
$shippingAddress = $orderData->getShippingAddress();

$shippingAddress is null. If I call $orderData->getBillingAddress(); return the correct address.

I don't understand why.


Try this :

 public function getShippingAddress($orderId) {
        $order = $this->getOrderData($orderId);
        /* check order is not virtual */
        if(!$order->getIsVirtual()) {
            $orderShippingId = $order->getShippingAddressId();
            $address = $this->addressCollection->create()->addFieldToFilter('entity_id',array($orderShippingId))->getFirstItem();
            return $address;
        return null;

For detailed answer: link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.