Skip to content

Instantly share code, notes, and snippets.

@celsowhite
Last active October 1, 2016 03:16
Show Gist options
  • Save celsowhite/69bfb8caf8e65e9d9016 to your computer and use it in GitHub Desktop.
Save celsowhite/69bfb8caf8e65e9d9016 to your computer and use it in GitHub Desktop.
Shopify Shipping Confirmation Email Template
<!--
Adjustments to the Shopify 'Shipping Confirmation' email template to show partially fulfilled items.
-->
<title>Shipping confirmation for order {{ name }}</title>
<!-- If all items were fulfilled -->
{% if fulfillment.item_count == item_count %}
<h3>All of your items were fulfilled!</h3>
<ul>
{% for line in fulfillment.line_items %}
<li>{{ line.quantity }}x {{ line.title }} is {{ line.line_price | money }}</li>
{% endfor %}
</ul>
You'll Be Charged: {{ subtotal_price | money }}
<!-- Else only partial items were fulfilled (partial products or partial quantity of a single product) -->
{% else %}
<!-- List the fulfilled items from this partial order so the user knows what they are recieving -->
<h3>Fulfilled Items</h3>
<!-- Assign variable for the partial price to show the user later the amount they will be charged -->
{% assign partial_price = '0' %}
<ul>
<!-- Loop through products that were fulfilled and the exact quantity that was fulfilled -->
{% for line in fulfillment.line_items %}
<li>{{ line.quantity }}x {{ line.title }} is {{ line.line_price | money }}</li>
<!-- Keep adding the partial price of each item so we know the $ amount of the order that was fulfilled -->
{% capture temp_partial_price %}{{ partial_price | plus:line.line_price }}{% endcapture %}
{% assign partial_price = temp_partial_price %}
{% endfor %}
</ul>
<!-- List the unfulfilled items so the user knows what they are not receiving -->
<h3>Unfulfilled Items</h3>
<ul>
<!-- Loop through all items -->
{% for item in line_items %}
{% assign found_item = false %}
<!-- Loop through fulfilled line items -->
{% for fulfilled_item in fulfillment.fulfillment_line_items %}
<!-- If an item is found in the list of fulfilled items -->
{% if item.id == fulfilled_item.line_item.id %}
{% assign found_item = true %}
<!-- If a certain quantity of the item was filled but not the entire then show the exact quantity that wasn't fulfilled -->
{% unless item.quantity == fulfilled_item.quantity %}
<li>{{ item.quantity | minus: fulfilled_item.quantity }}x {{ item.title }} {{ item.image | img_url: 'small' | img_tag }}</li>
{% endunless %}
{% endif %}
{% endfor %}
<!-- If item was not found in fulfilled items (i.e the full quantity couldn't be fulfilled) -->
{% unless found_item %}
<li>{{ item.quantity }}x {{ item.title }} {{ item.image | img_url: 'small' | img_tag }}</li>
{% endunless %}
{% endfor %}
</ul>
<!-- Print the partial_price variable used in the first 'for loop' to show the user how much they will be charged -->
<p>You'll Be Charged for the Fulfilled Items: {{ partial_price | money }}</p>
<p>The Full cost of your order was: {{ subtotal_price | money }}</p>
<!-- If the subtotal of the order was greater than $200 then give a discount code -->
{% if subtotal_price > 20000 %}
<p>You get 30% Off!</p>
{% else %}
<p>You get 20% Off!</p>
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment