Adding Contract details to Emails and Invoice Templates

Adding Contract details to Emails and Invoice Templates

{contract} is template function can be used in email templates and invoice template to dynamically load related contract details

Usage


In email templates you wish to attach something, use following tag:

{contract [attributes]}

 

Available attributes:

Attribute Name

Type

Required

Description

Attribute Name

Type

Required

Description

id

int

Yes

Related item (invoice,account,order,domain) id

for

string

Yes

Item type, one of: invoice, account, order, domain

multiple

bool

No

When set to false (default), function will load single contract details into  {$contract} template variable.

When set to true function will load multiple contracts (if any) to {$contracts} variable. Use true with type='invoice' or type='order'

Contract details available


Contract is loaded from database and gives you access to following details:

Variable

Type

Description

Variable

Type

Description

{$contract.id}

int

Database contract id

{$contract.number}

int

Human-readable contract number

{$contract.created_at}

datetime

Contract creation date

{$contract.accepted_at}

datetime

If accepted, contract acceptance date

{$contract.accepted_by}

string

If accepted, person who accepted contract

{$contract.expires}

date

Contract expiration date (if any)

{$contract.status}

string

One of: 'Draft','Pending','Active','Expired','Canceled'

{$contract.public_notes}

string

Public notes added to contract

Use in invoice template


To load all contracts related to invoice into its template, edit invoice template in Settings→Billing→Document Templates and add:

{contract for='invoice' id=$invoice.id multiple=true}

Below this call execution you will get access to  {$contracts} array:

{foreach from=$contracts item=contract} Related contract: {$contract.number} {/foreach}

 

Use in email template


To load contract related to account/domain/order into related email template, edit email template in Settings→Email templates and add

For account-related emails:

{contract for='account' id=$service.id}

For domain-related emails:

{contract for='domain' id=$domain.id}

 

Below above call executions you will get access to  {$contract} array:

Related contract: {$contract.number}

 

For order-related emails:

{contract for='order' id=$order.id multiple=true}

Below this call execution you will get access to  {$contracts} array:

{foreach from=$contracts item=contract} Related contract: {$contract.number} {/foreach}