> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supercycle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Shopify notifications

> Customize Shopify's order and customer emails for rentals, subscriptions, and charges with Liquid snippets

Shopify sends its own transactional emails, such as order confirmation, shipping updates, and refund notifications, directly from your store. They're separate from [Supercycle notifications](/supercycle-notifications), which cover rental, return, and subscription events. Because Supercycle products are sold through Shopify checkout, many customer emails and your staff notifications still come from Shopify.

To make those emails work for rental, membership, and subscription orders, extend Shopify's notification templates with the Liquid snippets on this page. They read Supercycle data from the order and its line items, so you can show rental start and end dates, word subscription orders differently from one-off purchases, tell customers about a charge, or link them to customer accounts to manage a subscription. Templates are edited under <Icon icon="shopify" iconType="solid" /> **[Notifications](https://admin.shopify.com/settings/notifications)**.

***

## Add a snippet to a template

<Steps>
  <Step title="Open notifications">
    Go to <Icon icon="shopify" iconType="solid" /> **[Notifications](https://admin.shopify.com/settings/notifications)**.
  </Step>

  <Step title="Open a template">
    Open the template you want to edit, for example **Order confirmation**, **New order**, or **Order edited**.
  </Step>

  <Step title="Paste the snippet">
    Copy the snippet you need from below and paste it into the subject line or the email body.
  </Step>

  <Step title="Preview and save">
    Select **Preview** to check how the email renders, then select **Save**.
  </Step>

  <Step title="Send a test">
    From the same screen, send a test email to yourself to check the content with real order data.
  </Step>
</Steps>

<Note>
  Order tags are applied after the order is created, so they aren't available when the email renders. Don't branch notification emails on tags. Use line item properties instead.
</Note>

***

## Snippets

<AccordionGroup>
  <Accordion title="Order has a subscription" icon="repeat">
    Shows different content when a line item has a subscription. This matches any order with a subscription, including recurring ones, so keep the message neutral or combine it with the recurring check below. Use it to link to customer accounts, where the customer manages their subscription.

    ```liquid Email body theme={null}
    {% 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>This order contains a subscription. <a href="{{ shop.url }}/account">Manage your subscription</a></p>
    {% else %}
      <p>Thank you for your order</p>
    {% endif %}
    ```
  </Accordion>

  <Accordion title="Recurring subscription order" icon="rotate">
    Shows different content when the order is a recurring one. Recurring orders created by Supercycle carry a `rental_id` line item property. The original checkout order doesn't.

    ```liquid Email body theme={null}
    {% assign is_recurring = false %}
    {% for line_item in line_items %}
      {% for prop in line_item.properties %}
        {% if prop.first == 'rental_id' %}
          {% assign is_recurring = true %}
        {% endif %}
      {% endfor %}
    {% endfor %}

    {% if is_recurring %}
      <p>Thank you for your subscription order</p>
    {% else %}
      <p>Thank you for your order</p>
    {% endif %}
    ```

    To change the subject too, paste this whole snippet, including the detection loop, into **Email subject**. It's the same check written with `{%-` whitespace control so the subject renders on one line.

    ```liquid Email subject theme={null}
    {%- assign is_recurring = false -%}
    {%- for line_item in line_items -%}
      {%- for prop in line_item.properties -%}
        {%- if prop.first == 'rental_id' -%}{%- assign is_recurring = true -%}{%- endif -%}
      {%- endfor -%}
    {%- endfor -%}
    {%- if is_recurring -%}
      Thanks for your subscription order, {{ customer.first_name }}
    {%- else -%}
      Thanks for your order, {{ customer.first_name }}
    {%- endif -%}
    ```

    <Warning>
      Don't use `order.source_name == 'subscription_contract'` to detect recurring orders. Shopify has changed `source_name` values without notice, and initial checkout orders can match this condition too.
    </Warning>
  </Accordion>

  <Accordion title="Rental start and end dates" icon="calendar">
    Shows the start and end dates of the line items. It works best when every product has fixed dates on. Add it to Shopify's default notifications to show the dates when your template doesn't output line item properties.

    ```liquid Email body theme={null}
    {% 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 %}
    ```
  </Accordion>

  <Accordion title="Rental dates in staff notifications" icon="bell">
    Shows the rental dates for each product in a staff notification such as **New order**. Place it inside the line item loop, where `line` is each line item.

    ```liquid Line item loop theme={null}
    {%- 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 -%}
    ```
  </Accordion>

  <Accordion title="Order has a charge" icon="credit-card">
    Shows different content when the order is for a charge created in Supercycle rather than a normal order.

    ```liquid Email body theme={null}
    {% 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 %}
    ```
  </Accordion>
</AccordionGroup>
