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.
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.
Exclude a specific line item
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.
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:
<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>
Get variant options by name
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).
Shopify limits the number of variant options to three. If you need to extend the customization of your products, then you can use line items properties. Apps like Infinite Options or Custom Product Builder use line item properties to store customer personalization choices.
The code snippet extracts the Engraving and Gift Wrapping options from line item properties.
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
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.
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.
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.
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 }}
Barcode image
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:
An order may be refunded partially more than once. Each refund has a list of refund_line_items. The code snippet above leverages the flat_map filter to get a single list of refunded line items from all refunds.