Skip to main content

Order has a subscription

Use to display different content if line item has a subscription. It can be used to show a link to your customer accounts, where the customer can manage their subscription.
{% assign has_subscription = false %}
{% for line_item in line_items %}
  {% if line_item.selling_plan_allocation %}
    {% assign has_subscription = true %}
    {% break %}
  {% endif %}
{% endfor %}

{% if has_subscription %}
  <p>You’ve started a subscription. <a href="{{ shop.url }}/account">Manage your subscription</a></p>
{% else %}
  <p>Thank you for your order</p>
{% endif %}

Order vs recurring subscription Order

Use to display different content if it’s a recurring order
{% if order.source_name == 'subscription_contract' %}
  <p>Thank you for your subscription order</p>
{% else %}
  <p>Thank you for your order</p>
{% endif %}
Use can also use it in the email subject
{%- if order.source_name == 'subscription_contract' -%}
  Thanks for your subscription order, {{ customer.first_name }} 
{%- else -%} 
  Thanks for your order, {{ customer.first_name }} 
{%- endif -%}

Show start and end dates

Use to show the start and end dates of the line items. This example code works best when all the products have fixed dates enabled.
{% assign start_date = '' %}
{% assign end_date = '' %}

{% for line_item in order.line_items %}
  {% for prop in line_item.properties %}
    {% if prop.first == 'Start date' %}
      {% assign start_date = prop.last %}
    {% elsif prop.first == 'End date' %}
      {% assign end_date = prop.last %}
    {% endif %}
  {% endfor %}
{% endfor %}

{% if start_date != '' %}
  <p><strong>Start date:</strong> {{ start_date }}</p>
{% endif %}
{% if end_date != '' %}
  <p><strong>End date:</strong> {{ end_date }}</p>
{% endif %}
You can incorporate this into Shopify’s default notifications to display the dates in the product list if your template isn’t outputting the line item properties.

Adding rental dates to staff notifications

To display rental start and end dates in staff notifications (like “New order” notifications), add this code within the line item loop in your notification template:
{%- assign rental_start_date = '' -%}
{%- assign rental_end_date = '' -%}
{%- for prop in line.properties -%}
  {%- if prop.first == 'Start date' -%}
    {%- assign rental_start_date = prop.last -%}
  {%- elsif prop.first == 'End date' -%}
    {%- assign rental_end_date = prop.last -%}
  {%- endif -%}
{%- endfor -%}
{%- if rental_start_date != '' or rental_end_date != '' -%}
  <p class="order-list__item-variant" style="margin-top: 4px;">
    <strong>Rental details</strong><br>
    {%- if rental_start_date != '' -%}
      Start date: {{ rental_start_date }}<br>
    {%- endif -%}
    {%- if rental_end_date != '' -%}
      End date: {{ rental_end_date }}
    {%- endif -%}
  </p>
{%- endif -%}
This code should be placed inside the line item loop (where line represents each line item) to display rental dates for each product in the order.

Check if the order has a charge

Use to show different content if the order notification is a normal order or for a charge created in Supercycle.
{% assign has_charge = false %}
{% assign charge_reason = '' %}

{% for line_item in order.line_items %}
  {% for prop in line_item.properties %}
    {% if prop.first == 'Charge' %}
      {% assign has_charge = true %}
      {% assign charge_reason = prop.last %}
    {% endif %}
  {% endfor %}
{% endfor %}

{% if has_charge %}
  <p>You have been charged: {charge_reason} </p>
{% else %}
  <p>Thank you for your order</p>
{% endif %}