Exporteo Help
Search…
Useful code snippets

If you want to calculate a delivery date by adding a certain number of days to date when an order was placed, then you need to use the following trick.
{%- assign three_days_seconds = 3 | times: 24 | times: 60 | times: 60 %}
<DeliveryDate>{{order.created_at | date: "%s" | plus: three_days_seconds | date: "%Y-%m-%d" }}</DeliveryDate>
What does the code do?
The first line calculates the number of seconds contained within 3 days. You might have typed 259200 right away, however, calculating it this way makes it easier to modify to a different number of days, and looks less of a magic number.
The second line converts the order creation date to a Unix timestamp , which is the number of seconds since 1970-01-01 00:00:00, adds the calculated number of seconds within the days, and finally converts the date back to a desired format.

The recommended way to exclude line items is to use a filter. For example, you can filter out products of a certain vendor, or tagged with a specific tag.
Exclude line items of vendor X
Exclude items tagged with Y
Make sure that the checkbox "Exclude line items not matching the filter" is enabled.
Nevertheless, if you need a more fine-tuned solution to skip a specific line item, then you can use an if statement in the output template code. Let's say you want to exclude a line item named "Donation". You can use the following expression:
{%- if line_item.name != "Donation" -%} ... item details ... {%- endif -%}
For JSON format, you'll need an extra check to control when to output a comma between subsequent elements.
CSV
JSON
XML
SKU,Title,Price,Quantity
{%- for line_item in order.line_items %}
{%- if line_item.title != "Donation" %}
{{ line_item.sku -}},
{{- line_item.title -}},
{{- line_item.price -}},
{{- line_item.quantity -}}
{%- endif -%}
{%- endfor %}
{
"line_items": [
{%- for item in order.line_items %}
{%- if item.title != "Description" %}
{
"sku": {{ item.sku | json }},
"title": {{ item.title | json }},
"price": {{ item.price | json }},
"quantity": {{ item.quantity | json }}
}
{%- assign next_item = order.line_items[forloop.index] -%}
{%- if forloop.last == false and next_item.title != "Description" -%}
,
{%- endif %}
{%- endif %}
{%- endfor %}
]
}
<items>
{%- for item in order.line_items %}
{%- if item.title != "Description" %}
<item>
<sku>{{item.sku}}</sku>
<title>{{item.title}}</title>
<price>{{item.price}}</price>
<quantity>{{item.quantity}}</quantity>
</item>
{%- endif %}
{%- endfor %}
</items>

You can use the following code snippet to get variant options by name. The example shows how to get options named Width, Depth, and Height. You can adjust the names to your needs. Please note that option names are case-sensitive (it matters if letters are uppercase or lowercase).
{%- for item in order.line_items %}
<item>
<width>{{item.options_with_values | where: "name", "Width" | map: "value" }}</width>
<depth>{{item.options_with_values | where: "name", "Depth" | map: "value" }}</depth>
<height>{{item.options_with_values | where: "name", "Height" | map: "value" }}</height>
</item>
{%- endfor %}

You can get the payment date from order.transactions:
{{ order.transactions | where: "kind", "sale" | where: "status", "success" | map: "created_at" | first | date: "%Y-%m-%d" }}

There is no variable for price after discount available directly, however, you can calculate it from item.price, item.discount_allocations, and item.quantity.
If you want to get price after discount for a single item, then you first need calculate the total discount value allocated to the item from item.discount_allocations
{%- assign total_discount = 0.0 %}
{%- for discount_allocation in item.discount_allocations %}
{%- assign total_discount = total_discount | plus: discount_allocation.amount %}
{%- endfor %}
Then you can calculate the unit discount value by dividing total_discount by item.quantity
{%- assign unit_discount = total_discount | divided_by: item.quantity | round: 2 %}
Finally, you can substract the calculated unit_discount from item.price to get unit price after discount.
{%- assign unit_price_after_discount = item.price | minus: unit_discount | round: 2%}
Putting the code snippets together to output unit item price per discount:
<items>
{%- for item in order.line_items %}
<item>
{%- assign total_discount = 0.0 %}
{%- for discount_allocation in item.discount_allocations %}
{%- assign total_discount = total_discount | plus: discount_allocation.amount %}
{%- endfor %}
{%- assign unit_discount = total_discount | divided_by: item.quantity | round: 2 %}
{%- assign unit_price_after_discount = item.price | minus: unit_discount | round: 2 %}
<unit_price_after_discount>{{ unit_price_after_discount }}</unit_price_after_discount >
</item>
{%- endfor %}
</items>
On the other hand, if you are looking for total item price after discount, then you need to first multiply item.price by item.quantity and then subtract total_discount.
<items>
{%- for item in order.line_items %}
<item>
{%- assign total_discount = 0.0 %}
{%- for discount_allocation in item.discount_allocations %}
{%- assign total_discount = total_discount | plus: discount_allocation.amount %}
{%- endfor %}
{%- assign total_price_after_discount = item.price | times: item.quantity | minus: total_discount | round: 2 %}
<total_price_after_discount>{{ total_price_after_discount }}</total_price_after_discount>
</item>
{%- endfor %}
</items>

If a customer pays for an order by a gift card then the information is recorded in {{ order.transactions }}. The transaction gateway is then gift_card. You can get the ID and last four characters of the gift card code from a transaction receipt.
{%- assign gift_card_receipt = order.transactions | where: "gateway", "gift_card" | map: "receipt" | first -%}
{{ gift_card_receipt.gift_card_id }}
{{ gift_card_receipt.gift_card_last_characters }}

If you export all items, then you can just use the {{ order.total_weight }} variable.
However, if you specified a filter, and selected the option to exclude items not matching the filter, then you'll need to calculate the total weight using the following code snippet.
{%- assign total_grams = 0 -%}
{%- for line_item in order.line_items -%}
{%- assign line_item_total_grams = line_item.grams | times: line_item.quantity -%}
{%- assign total_grams = total_grams | plus: line_item_total_grams -%}
{%- endfor -%}
{{ total_grams }}

When it comes to shipping cost, Shopify gives you only the total shipping price in the order.total_shipping_price_set variable which may or may not include taxes depending on the value of order.taxes_included. There is no variable that would hold shipping tax or a corresponding net/gross shipping price. To get the tax amount of the shipping cost, you'll need to calculate it from order.shipping_lines this way:
{%- assign shipping_tax = 0 %}
{%- for shipping_line in order.shipping_lines %}
{%- for shipping_tax_line in shipping_line.tax_lines %}
{%- assign shipping_tax = shipping_tax | plus: shipping_tax_line.price %}
{%- endfor %}
{%- endfor %}
{{ shipping_tax }}

Using Exporteo, you can generate a pick list PDF that includes barcode images which your logistics service can scan to speed up order fulfillment. To embed a barcode image you need to add the following code to the default PDF template:
<td><img src="https://barcode.tec-it.com/barcode.ashx?data={{line_item.variant.barcode}}&code=UPCA"/></td>
As you may notice, it makes use of an external service to generate the barcode image. Nevertheless, the TEC-IT barcode generator is a free service.
Here is an example preview of an order that includes UPC barcodes:
Copy link
On this page
Add days to the order creation date
Exclude a specific line item
Get variant options by name
Payment date
Price after discount
Gift card code
Total weight
Shipping tax
Barcode image