Snipcart Email Templates Customization Guide

This guide provides an overview of the custom helpers available for use in Snipcart email templates, enhancing the functionality and personalization of your e-commerce communications.

Custom Settings Helpers

Enhance your email templates with dynamic content from your Snipcart dashboard settings.

  • Settings.Signature: Inserts the footer text configured under the Orders & Invoices section.

    {{ Settings.Signature }}
  • Settings.BusinessAddress: Access various components of the business address configured in the Profile section of the dashboard. Use {{ Settings.BusinessAddress.XXX }}, where XXX is the field name. Supported fields are:

    • Company: Business name or domain if no name is configured.
    • Address1
    • Address2
    • City
    • Country: Two-letter country code.
    • PostalCode: Postal or ZIP code.
    • Province: Province or State (availability varies by country).
    • VatNumber: VAT number (availability varies by country).
      {{ Settings.BusinessAddress.Company }}
  • Settings.LogoUrl: Retrieves the logo URL for use in an <img> tag, set in the Orders & Invoices section.

    <img src="{{ Settings.LogoUrl }}" alt="Business Logo">
  • Settings.IncludeProductImagesInInvoice: Boolean helper for default invoice template.

Formatting Helpers

These helpers assist in presenting data in a more readable and aesthetically pleasing manner.

  • money: Formats monetary values according to your account's currency setting.
    {{ money }}
  • date: Formats dates. Optionally specify a date format.
    {{ date order.completionDate 'yyyy-MM-dd HH:mm:ss' }}
  • cleanHtml: Sanitizes and renders HTML markup directly in the template.
    {{ cleanHtml this.description }}
  • displayJsonValue: Displays values from a JSON object, specifying the object and the key.
    {{ displayJsonValue order.metadata "key" }}

Conditional Helpers

Utilize these helpers to control the display of template content based on specific conditions.

  • if_eq: Checks if a value equals an expected value, facilitating conditional rendering.

    {{ #if_eq order.paymentMethod 'CreditCard' }}
      <span>The payment method is Credit card!</span>
    {{ else }}
      <span>The payment method is not credit card, it is {{ order.paymentMethod }}.</span>
    {{ /if_eq }}
  • has_any: Verifies if an array contains elements, useful for checking non-empty lists.

    {{ #has_any order.items }}
      <span>Items contain some elements!</span>
    {{ else }}
      <span>Nothing in this...</span>
    {{ /has_any }}
  • contains: Determines if an array includes a specific element, aiding in targeted content display.

    {{ #contains this.categories 'Cat1' }}
      <span>Categories contain 'Cat1'</span>
    {{ else }}
      <span>Doesn't contain 'Cat1' category.</span>
    {{ /contains }}
  • has_items_from_category: Checks if the cart contains items from a specified category.

    {{ #has_items_from_category order.items 'Cat1' }}
      <span>Cart contains an item with category 'Cat1'</span>
    {{ else }}
      <span>Doesn't contain 'Cat1' category.</span>
    {{ /has_items_from_category }}
  • is_absolute_url: Verifies if a URL is absolute, ensuring link integrity.

    {{ #is_absolute_url this.url }}
      <span>{{ this.url }} is an absolute URL.</span>
    {{ else }}
      <span>{{ this.url }} is NOT an absolute URL.</span>
    {{ /is_absolute_url }}
  • sum and sum_money: Performs sum operations, with sum_money additionally formatting the result as a monetary value.

    <!-- Sum without formatting -->
    <div>{{ sum order.summary.subtotal }}</div>
    <!-- Sum with monetary formatting -->
    <div>{{ sum_money order.summary.subtotal }}</div>

Was this article helpful?