Get zipcode inside track.phtml to track shipment of a order
-
13-12-2019 - |
Question
How can I get the zipcode of the order inside the track.html file?
I tried this, but that does not work:
<?php echo $this->escapeHtml($this->getShippingAddress()->getPostcode()) ?>
Solution
The block type of the track.phtml
template is core/template
so it's default without a method like $this->getShippingMethod()
.
If you check the shipment_new.html
email template somewhere around the bottom the tracking block is included with the following statement
{{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}}
This means both the order and shipment are available in the data of the block class. Which means you can do this
<?php echo $this->escapeHtml($this->getOrder()->getShippingAddress()->getPostcode()) ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange