Email template variables & objects

How to use customer data, transaction data, and account information in your email templates. Personalize or add conditional logic to Emails.

Larry Brager avatar
Written by Larry Brager
Updated over a week ago

On PayWhirl, you can use our default email templates or customize your templates if you'd like to add some personalization. We provide variables (listed below) that you can use to customize your templates within the HTML.  

For example, if you wanted to say "Hello Jane," and use your customer's first name in an Email template, you would use the "First Name" property in the customer object:

Hello {{ customer.first_name }},

You can use these "variables" to inject data into your template and customize your Email templates with data from your PayWhirl account. Each email that PayWhirl sends contains different OBJECTS relating to the type of email that is sent. Here is a list of the Emails and the objects included for each:

OBJECT TYPES

  • My - Contains variables about the account.

  • Customer - Contains variables about the customer.

  • Profile Questions - Contains an array of customer profile questions & answers.

  • Plan - Contains variables about the plan settings.

  • Subscription - Contains variables about the subscription from the transaction.

  • Card - Contains variables about the payment methods from the transaction. 

  • Invoice - Contains variables about the invoice from the transaction.

  • Invoice Items - Contains an array of individual items on an invoice.

EMAIL TEMPLATES - INCLUDED OBJECTS

  • Welcome Email - my, customer

  • New Subscription - my, customer, plan, subscription

  • Canceled Subscription - my, customer, plan, subscription

  • Add or Remove Payment Method - my, customer, card

  • Payment Reminder - my, customer, plan, invoice, invoiceitems

  • Payment Receipt - my, customer, plan, invoice, invoiceitems

  • Payment Request - my, customer, plan, invoice, invoiceitems

  • Payment Refund - my, customer, plan, invoice, invoiceitems

  • Unsuccessful Payment - my, customer, plan, invoice, invoiceitems

  • Gift Code Redeemed - my, customer, invoice, invoiceitems

  • Password Reminder - my, customer

  • Customer Profile or Subscription Updated - my, customer, plan, subscription

Each Email contains data that is specific to the purpose of the email, so all templates do not have access to the same data. PayWhirl's email template system is built on Twig, which is very similar to other template languages like Liquid from Shopify or Freemarker.

The "my" object contains information about your business. The available properties are:

{{ my.first_name }}
{{ my.last_name }}
{{ my.company_name }}
{{ my.country }}
{{ my.email }}
{{ my.phone }}
{{ my.address }}
{{ my.city }}
{{ my.state }}
{{ my.zip }}
{{ my.currency }}
{{ my.slug }}
{{ my.application_fee_percent }}
{{ my.send_reminders }}
{{ my.shopify_domain }}
{{ my.shopify_error }}
{{ my.gateway_id }}
{{ my.timezone }}


The "customer" object contains information about the customer making the purchase. The available properties are:

{{ customer.first_name }}
{{ customer.last_name }}
{{ customer.email }}
{{ customer.phone }}
{{ customer.address}}
{{ customer.city }}
{{ customer.state }}
{{ customer.zip }}
{{ customer.country }}
{{ customer.default_card }}
{{ customer.gateway_reference }}
{{ customer.gateway_type }}
{{ customer.gateway_id }}
{{ customer.currency }}
{{ customer.deleted_at }}
{{ customer.utm_source }}
{{ customer.utm_medium }}
{{ customer.utm_term }}
{{ customer.utm_content }}
{{ customer.utm_campaign }}
{{ customer.utm_group }}
{{ customer.metadata }}
{{ customer.shopify_redact_at }}


You can also find out attributes about the customer's shipping address by using these "shipping" variables:

{{ shipping.first_name }}
{{ shipping.last_name }}
{{ shipping.email }}
{{ shipping.phone }}
{{ shipping.address}}
{{ shipping.city }}
{{ shipping.state }}
{{ shipping.zip }}
{{ shipping.country }}


If you have customers with multiple profiles or addresses, you can use the "addresses" array to cycle through all of the customer's stored addresses.

{{ address.first_name }}
{{ address.last_name }}
{{ address.phone }}
{{ address.address }}
{{ address.city }}
{{ address.state }}
{{ address.zip }}
{{ address.country }}


Example Addresses Loop:

<p>Your addresses:</p>
{% for address in addresses %}
<p>
   {{ address.first_name }}<br />
   {{ address.last_name }}<br />
   {{ address.phone }}<br />
   {{ address.address }}<br />
   {{ address.city }}<br />
   {{ address.state }}<br />
   {{ address.zip }}<br />
   {{ address.country }}
</p>
{% endfor %}


The "plan" object contains information about the subscription plan's general settings. The available properties are:

{{ plan.name }}
{{ plan.setup_fee }}
{{ plan.installments }}
{{ plan.require_shipping }}
{{ plan.require_tax }}
{{ plan.active }}
{{ plan.image }}
{{ plan.description }}
{{ plan.billing_amount }}
{{ plan.billing_interval }}
{{ plan.billing_frequency }}
{{ plan.trial_days }}
{{ plan.sku }}
{{ plan.currency }}
{{ plan.billing_cycle_anchor }}
{{ plan.file }}
{{ plan.autorenew_plan }}
{{ plan.tags }}
{{ plan.enabled }}


The "subscription" object contains information about the subscription on the customer's account. The available properties are:

{{ subscription.customer_id }}
{{ subscription.plan_id }}
{{ subscription.quantity }}
{{ subscription.current_period_start }}
{{ subscription.current_period_end }}
{{ subscription.trial_start }}
{{ subscription.trial_end }}
{{ subscription.installment_plan }}
{{ subscription.installments_left }}


The "card" object contains information about the card on file being used for the subscription. The available properties are:

{{ card.gateway_reference }}
{{ card.brand }}
{{ card.funding }}
{{ card.country }}
{{ card.last4 }}
{{ card.gateway_id }}
{{ card.customer_id }}


The "invoice" object contains information about a specific invoice. The available properties are:

{{ invoice.id }}
{{ invoice.customer_id }}
{{ invoice.discount_id }}
{{ invoice.subscription_id }}
{{ invoice.charge_id }}
{{ invoice.additional_charge_id }}
{{ invoice.card_id }}
{{ invoice.shipping }}
{{ invoice.tax }}
{{ invoice.attempted }}
{{ invoice.attempt_count }}
{{ invoice.currency }}
{{ invoice.due_date }}
{{ invoice.next_payment_attempt }}
{{ invoice.period_end }}
{{ invoice.period_start }}
{{ invoice.status }}
{{ invoice.paid }}
{{ invoice.subtotal }}
{{ invoice.discount }}
{{ invoice.shipping_total }}
{{ invoice.tax_total }}
{{ invoice.amount_due }}
{{ invoice.webhooks_delivered_at }}
{{ invoice.created_at }}
{{ invoice.updated_at }}
{{ invoice.paid_on }}
{{ invoice.deleted_at }}
{{ invoice.promo_id }}
{{ invoice.promo_code }}
{{ invoice.promo_uses }}
{{ invoice.integration_errors }}
{{ invoice.address_id }}
{{ invoice.carrier }}
{{ invoice.service }}
{{ invoice.tracking_number }}
{{ invoice.is_order }}
{{ invoice.shopify_created_at }}
{{ invoice.is_queued }}
{{ invoice.metadata }}


The "invoiceitems" object is an array that contains the information about the individual items on the customer's invoice. To display all the items you need to create a loop.

invoiceitems
.0
{{ invoiceitems.0.type }}
{{ invoiceitems.0.customer_id }}
{{ invoiceitems.0.invoice_id }}
{{ invoiceitems.0.subscription_id }}
{{ invoiceitems.0.quantity }}
{{ invoiceitems.0.description }}
{{ invoiceitems.0.amount }}
{{ invoiceitems.0.currency }}
{{ invoiceitems.0.sku }}
{{ invoiceitems.0.id }}
{{ invoiceitems.0.user_id }}
{{ invoiceitems.0.created_at }}
{{ invoiceitems.0.updated_at }}
{{ invoiceitems.0.deleted_at }}
{{ invoiceitems.0.image }}
{{ invoiceitems.0.min }}
{{ invoiceitems.0.max }}
{{ invoiceitems.0.max_plan_limit }}
{{ invoiceitems.0.widget_uuid }}

.1
{{ invoiceitems.1.type }}
{{ invoiceitems.1.customer_id }}

etc...


Example Invoice Items Loop:

<p>Invoice Items</p>
{% for items in invoiceitems %}
<p>
<strong>ITEM</strong><br/>
<strong>{{ invoiceitems.type }}</strong><br/>
<strong>{{ invoiceitems.customer_id }}</strong><br/>
<strong>{{ invoiceitems.invoice_id }}</strong><br/>
<strong>{{ invoiceitems.subscription_id }}</strong><br/>
<strong>{{ invoiceitems.quantity }}</strong><br/>
<strong>{{ invoiceitems.description }}</strong><br/>
<strong>{{ invoiceitems.amount }}</strong><br/>
<strong>{{ invoiceitems.currency }}</strong><br/>
<strong>{{ invoiceitems.sku }}</strong><br/>
<strong>{{ invoiceitems.id }}</strong><br/>
<strong>{{ invoiceitems.user_id }}</strong><br/>
<strong>{{ invoiceitems.created_at }}</strong><br/>
<strong>{{ invoiceitems.updated_at }}</strong><br/>
<strong>{{ invoiceitems.deleted_at }}</strong><br/>
<strong>{{ invoiceitems.image }}</strong><br/>
<strong>{{ invoiceitems.min }}</strong><br/>
<strong>{{ invoiceitems.max }}</strong><br/>
<strong>{{ invoiceitems.max_plan_limit }}</strong><br/>
<strong>{{ invoiceitems.widget_uuid }}</strong><br/>
</p>
<br>
{% endfor %}


If you'd like to use customer profile questions or answers you need to create a loop to display the data as the "profile_questions" object contains an array of questions/answers:

profile_questions
.exists
.0
{{ profile_questions.0.label }}
{{ profile_questions.0.answer }}

.1
{{ profile_questions.1.label }}
{{ profile_questions.1.answer }}

etc...


Example Profile Questions / Answers Loop:

<p>Your answers:</p>
{% for question in profile_questions %}
<p>
<strong>{{ question.label }}</strong><br/>
{{ question.answer }}
</p>
{% endfor %}
</div>

Note: Using the "Send Test" option to test the email templates uses fake data instead of live data from your account. To test with live data, you should subscribe a customer to the plan you want to test. 

Related Articles:

Please let us know if you have any questions. 

Sincerely,
The PayWhirl Team

Did this answer your question?