Customizing "non blank headers" with my own labels

In our default order confirmation template, there is a block after all the line items that reads like:

{% for h in order.nonBlankHeaders %}
<tr>
  <td><strong>{{ h.label }}:</strong></td>
  <td>{{ h.value }}</td>
</tr>
{% /for %}

What this is doing is going through the set of order headers that are "non blank" (or put another way, have been "filled in") and listing them out in a table, one by one. The list of things that can appear in this are as follows:

  • Customer PO
  • Payment terms
  • Shipping method
  • Start ship date
  • Cancel date
  • Notes

The gory details on these are available towards the bottom of the field listing here.

What's the problem?

The nonBlankHeaders list is a nice convenience for showing headers from the order that we think you (and your customer) will be interested in. The problem is that the h.label part of the data generated by nonBlankHeaders is always in English, and if you want to show something else for these, well, you basically can't use nonBlankHeaders. Boo.

How can I show these headers with my own custom labels?

To show the headers, you will need to list out <tr> blocks for each header you want to show. For example, if you just wanted to show the customerPO and notes fields with Spanish labels, you could have something like this:

<tr>
  <td><strong>Número de cliente para:</strong></td>
  <td>{{ order.customerPO }}</td>
</tr>
<tr>
  <td><strong>Comentarios:</strong></td>
  <td>{{ order.notes }}</td>
</tr>

If you wanted to emulate our default behaviour of only showing the fields when they're non-blank, you could wrap each <tr> block in an {% if %} like this:

{% if order.customerPO %}
<tr>
  <td><strong>Número de cliente para:</strong></td>
  <td>{{ order.customerPO }}</td>
</tr>
{% /if %}

{% if order.notes %}
<tr>
  <td><strong>Comentarios:</strong></td>
  <td>{{ order.notes }}</td>
</tr>
{% /if %}

Recent Discussions

04 Sep, 2012 08:42 AM
31 Aug, 2012 10:34 PM
30 Aug, 2012 09:46 PM
24 Aug, 2012 10:37 PM