Skip to main content
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 3 months 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.address }}
{{ my.city }}
{{ my.company_name }}
{{ my.country }}
{{ my.email }}
{{ my.first_name }}
{{ my.last_name }}
{{ my.logo }}
{{ my.phone }}
{{ my.slug }}
{{ my.state }}
{{ my.zip }}


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

{{ customer.address}}
{{ customer.city }}
{{ customer.country }}
{{ customer.currency }}
{{ customer.email }}
{{ customer.first_name }}
{{ customer.id }}
{{ customer.last_name }}
{{ customer.new_password_token }}
{{ customer.phone }}
{{ customer.state }}
{{ customer.zip }}


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

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


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.address }}
{{ address.city }}
{{ address.country }}
{{ address.first_name }}
{{ address.last_name }}
{{ address.phone }}
{{ address.state }}
{{ address.zip }}


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.billing_amount }}
{{ plan.billing_cycle_anchor }}
{{ plan.billing_dates }}
{{ plan.billing_frequency }}
{{ plan.billing_interval }}
{{ plan.created_at }}
{{ plan.currency }}
{{ plan.description }}
{{ plan.file }}
{{ plan.id }}
{{ plan.image }}
{{ plan.installments }}
{{ plan.name }}
{{ plan.setup_fee }}
{{ plan.sku }}
{{ plan.tags }}
{{ plan.trial_days }}


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

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


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

{{ card.brand }}
{{ card.country }}
{{ card.gateway_id }}
{{ card.gateway_reference }}
{{ card.last4 }}
{{ card.title }}


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

{{ invoice.amount_due }}
{{ invoice.attempt_count }}
{{ invoice.charge_id }}
{{ invoice.created_at }}
{{ invoice.currency }}
{{ invoice.discount }}
{{ invoice.due_date }}
{{ invoice.id }}
{{ invoice.next_payment_attempt }}
{{ invoice.paid }}
{{ invoice.paid_on }}
{{ invoice.period_end }}
{{ invoice.period_start }}
{{ invoice.promo_code }}
{{ invoice.promo_id }}
{{ invoice.shipping_total }}
{{ invoice.status }}
{{ invoice.subtotal }}
{{ invoice.tax_total }}
{{ invoice.tracking_number }}


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.amount }}
{{ invoiceitems.0.currency }}
{{ invoiceitems.0.description }}
{{ invoiceitems.0.image }}
{{ invoiceitems.0.quantity }}
{{ invoiceitems.0.sku }}
{{ invoiceitems.0.type }}

.1
{{ invoiceitems.1.type }}
{{ invoiceitems.1.description }}

etc...


Example Invoice Items Loop:

<p>Invoice Items</p>
{% for item in invoiceitems %}
<p>
<strong>ITEM</strong><br/>
<strong>{{ item.type }}</strong><br/>
<strong>{{ item.description }}</strong><br/>
<strong>{{ item.quantity }}</strong><br/>
<strong>{{ item.amount }}</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?