You can use the following variable to show custom customer fields stored against an order's shipping address in the Order Template.
- order.get_shipping_detail.custom_fields.field_name
Replace field_name with the name of the field. Use lowercase and add an underscore to replace all characters which are not letters or numbers.
Here is an example of how you can modify the default Order Template to show a custom customer field specified against the shipping address.
Default Code
{% if (order.get_shipping_detail) and (order.get_shipping_detail.use_shipping_details) %}
<div class="shipping">
<h3>Shipping Address</h3>
<h4>{{ order.get_shipping_detail.full_name }}{% if order.get_shipping_detail.company %}<br>{{ order.get_shipping_detail.company }}{% endif %}</h4>
<span>
{{order.get_shipping_detail.address}}<br />
{{order.get_shipping_detail.city}}, {{order.get_shipping_detail.state}} {{order.get_shipping_detail.country_name}} {{ order.get_shipping_detail.zip }}
</span>
</div>
{% else %}
Custom Code
Add the code in red to the default code shown above as follows:
{% if (order.get_shipping_detail) and (order.get_shipping_detail.use_shipping_details) %}
<div class="shipping">
<h3>Shipping Address</h3>
<h4>{{ order.get_shipping_detail.full_name }}{% if order.get_shipping_detail.company %}<br>{{ order.get_shipping_detail.company }}{% endif %}</h4>
<span>
{{order.get_shipping_detail.address}}<br />
{{order.get_shipping_detail.city}}, {{order.get_shipping_detail.state}}
{{order.get_shipping_detail.custom_fields.locality}}
{{order.get_shipping_detail.country_name}} {{ order.get_shipping_detail.zip }}
</span>
</div>
{% else %}
Comments
0 comments
Please sign in to leave a comment.