Difference between revisions of "Customizing Email Templates"
(18 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | Merchants can fully customize the | + | Merchants can fully customize the emails sent by Ablecommerce. The email templates defined in Ablecommerce can include plain text, static HTML, and even dynamic information with the help of a full fledged template engine. |
− | + | nVelocity is used as the template engine to process the email templates. Email templates are written in velocity template language (VTL), which is extremely simple and powerful. | |
In a velocity template, certain objects put in the velocity context, can be accessed directly in a straight forward manner. For example if a ‘Store’ object, named “store” is available in the context, then using $store.Name we will get the name of the store. Similarly any method available in the ‘Store’ object can be called directly. | In a velocity template, certain objects put in the velocity context, can be accessed directly in a straight forward manner. For example if a ‘Store’ object, named “store” is available in the context, then using $store.Name we will get the name of the store. Similarly any method available in the ‘Store’ object can be called directly. | ||
− | + | In Ablecommerce certain pre-defined objects are made available to the velocity context for an email template depending on the event that triggered the email. The following table illustrates these objects and their availability for different events. | |
− | + | {| {{Prettytable}} | |
+ | |- {{Hl3}} | ||
+ | !Object!!Type!!Available For | ||
+ | |- | ||
+ | |$store||CommerceBuilder.Stores.Store||All Events | ||
+ | |- | ||
+ | |$order||CommerceBuilder.Orders.Order||OrderStatusUpdated<br/>PaymentAuthorized<br/>PaymentCaptured<br/>PaymentCapturedPartial<br/>PaymentAuthorizationFailed<br/>PaymentCaptureFailed<br/>OrderPlaced<br/>OrderCancelled<br/>OrderPaidPartial<br/>OrderPaid<br/> OrderPaidNoShipments<br/>OrderPaidCreditBalance<br/>ShipmentShipped<br/>OrderShipped<br/>OrderShippedPartial<br/>GiftCertificateValidated<br/>OrderNoteAddedByCustomer | ||
+ | |- | ||
+ | |$customer||CommerceBuilder.Users.User||OrderStatusUpdated<br/>PaymentAuthorized<br/>PaymentCaptured<br/>CustomerPasswordRequest<br/>PaymentCapturedPartial<br/>PaymentAuthorizationFailed<br/>PaymentCaptureFailed<br/>OrderPlaced<br/> OrderCancelled<br/>OrderPaidPartial<br/>OrderPaid<br/>OrderPaidNoShipments<br/>OrderPaidCreditBalance<br/>ShipmentShipped<br/>OrderShipped,OrderShippedPartial<br/>GiftCertificateValidated<br/>OrderNoteAddedByCustomer | ||
+ | |- | ||
+ | |$oldstatusname||System.String||OrderStatusUpdated | ||
+ | |- | ||
+ | |$products||CommerceBuilder.Products.Product||LowInventoryItemPurchased | ||
+ | |- | ||
+ | |$payment||CommerceBuilder.Payments.Payment||PaymentAuthorized<br/>PaymentCaptured<br/>PaymentCapturedPartial<br/>PaymentAuthorizationFailed<br/>PaymentCaptureFailed | ||
+ | |- | ||
+ | |$resetPasswordLink||System.String||CustomerPasswordRequest | ||
+ | |- | ||
+ | |$shipment||CommerceBuilder.Shipping.OrderShipment||ShipmentShipped | ||
+ | |- | ||
+ | |$giftcertificate||CommerceBuilder.Payments.GiftCertificate||GiftCertificateValidated | ||
+ | |- | ||
+ | |$note||CommerceBuilder.Orders.OrderNote||OrderNoteAddedByCustomer | ||
+ | |||
+ | |} | ||
+ | |||
+ | |||
+ | Using the above objects in email templates, almost any type of email can be generated. Here are few examples. | ||
+ | |||
+ | Merchant Enters: | ||
+ | <code><pre> | ||
+ | Dear $customer.PrimaryAddress.FirstName $customer.PrimaryAddress.LastName, | ||
+ | </pre></code> | ||
+ | AbleCommerce Sends: | ||
+ | <code><pre> | ||
+ | Dear Joe Smith, | ||
+ | </pre></code> | ||
+ | |||
+ | The example shown below demonstrates how a merchant might include an HTML table of items ordered. | ||
+ | |||
+ | Merchant Enters: | ||
<code> | <code> | ||
<pre> | <pre> | ||
− | + | <table> | |
− | + | ||
− | + | <tr> | |
− | + | <th>Name</th> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <th>SKU</th> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <th>Quantity</th> | |
− | + | </tr> | |
− | + | #foreach( $orderItem in $order.orderItems ) | |
+ | <tr> | ||
+ | |||
+ | <td>$orderItem.Name<br> | ||
+ | |||
+ | <td>$orderItem.Sku</td> | ||
+ | |||
+ | <td align=center>$orderItem.Quantity</td> | ||
+ | |||
+ | </tr> | ||
+ | |||
+ | #end | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | </table> | ||
+ | </pre></code> | ||
+ | |||
+ | |||
+ | AbleCommerce Sends: | ||
+ | <code><pre> | ||
+ | <table> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <th>Name</th> | ||
+ | |||
+ | <th>SKU</th> | ||
+ | |||
+ | <th>Quantity</th> | ||
+ | |||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td>128MB PC2100 DDR DIMM 184 Pin Memory Module</td> | ||
+ | |||
+ | <td>16X64D2100-CUSA</td> | ||
+ | |||
+ | <td align=center >1</td> | ||
+ | |||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td>CG814M Wireless Cable Modem</td> | ||
+ | |||
+ | <td>CG814MNA</td> | ||
+ | |||
+ | <td align=center >1</td> | ||
+ | |||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | |||
+ | <td>5.1 Channel PCI Surround-Sound Card</td> | ||
+ | |||
+ | <td>11000975</td> | ||
+ | |||
+ | <td align=center >1</td> | ||
+ | |||
+ | </tr> | ||
+ | |||
+ | </table> | ||
</pre> | </pre> | ||
</code> | </code> | ||
+ | |||
+ | In short, all basic programming constructs can be used in VTL. Loops can be done using #foreach, conditional statements can be done using #if-else. | ||
+ | |||
+ | For more information on nVelocity please visit [http://www.castleproject.org/others/nvelocity/index.html nVelocity Home Page]. | ||
+ | |||
+ | [[Category:AbleCommerce 7]] | ||
+ | [[Category:AbleCommerce Gold]] |
Latest revision as of 11:40, 15 August 2013
Merchants can fully customize the emails sent by Ablecommerce. The email templates defined in Ablecommerce can include plain text, static HTML, and even dynamic information with the help of a full fledged template engine.
nVelocity is used as the template engine to process the email templates. Email templates are written in velocity template language (VTL), which is extremely simple and powerful.
In a velocity template, certain objects put in the velocity context, can be accessed directly in a straight forward manner. For example if a ‘Store’ object, named “store” is available in the context, then using $store.Name we will get the name of the store. Similarly any method available in the ‘Store’ object can be called directly.
In Ablecommerce certain pre-defined objects are made available to the velocity context for an email template depending on the event that triggered the email. The following table illustrates these objects and their availability for different events.
Object | Type | Available For |
---|---|---|
$store | CommerceBuilder.Stores.Store | All Events |
$order | CommerceBuilder.Orders.Order | OrderStatusUpdated PaymentAuthorized PaymentCaptured PaymentCapturedPartial PaymentAuthorizationFailed PaymentCaptureFailed OrderPlaced OrderCancelled OrderPaidPartial OrderPaid OrderPaidNoShipments OrderPaidCreditBalance ShipmentShipped OrderShipped OrderShippedPartial GiftCertificateValidated OrderNoteAddedByCustomer |
$customer | CommerceBuilder.Users.User | OrderStatusUpdated PaymentAuthorized PaymentCaptured CustomerPasswordRequest PaymentCapturedPartial PaymentAuthorizationFailed PaymentCaptureFailed OrderPlaced OrderCancelled OrderPaidPartial OrderPaid OrderPaidNoShipments OrderPaidCreditBalance ShipmentShipped OrderShipped,OrderShippedPartial GiftCertificateValidated OrderNoteAddedByCustomer |
$oldstatusname | System.String | OrderStatusUpdated |
$products | CommerceBuilder.Products.Product | LowInventoryItemPurchased |
$payment | CommerceBuilder.Payments.Payment | PaymentAuthorized PaymentCaptured PaymentCapturedPartial PaymentAuthorizationFailed PaymentCaptureFailed |
$resetPasswordLink | System.String | CustomerPasswordRequest |
$shipment | CommerceBuilder.Shipping.OrderShipment | ShipmentShipped |
$giftcertificate | CommerceBuilder.Payments.GiftCertificate | GiftCertificateValidated |
$note | CommerceBuilder.Orders.OrderNote | OrderNoteAddedByCustomer |
Using the above objects in email templates, almost any type of email can be generated. Here are few examples.
Merchant Enters:
Dear $customer.PrimaryAddress.FirstName $customer.PrimaryAddress.LastName,
AbleCommerce Sends:
Dear Joe Smith,
The example shown below demonstrates how a merchant might include an HTML table of items ordered.
Merchant Enters:
<table> <tr> <th>Name</th> <th>SKU</th> <th>Quantity</th> </tr> #foreach( $orderItem in $order.orderItems ) <tr> <td>$orderItem.Name<br> <td>$orderItem.Sku</td> <td align=center>$orderItem.Quantity</td> </tr> #end <tr> </table>
AbleCommerce Sends:
<table>
<tr>
<th>Name</th>
<th>SKU</th>
<th>Quantity</th>
</tr>
<tr>
<td>128MB PC2100 DDR DIMM 184 Pin Memory Module</td>
<td>16X64D2100-CUSA</td>
<td align=center >1</td>
</tr>
<tr>
<td>CG814M Wireless Cable Modem</td>
<td>CG814MNA</td>
<td align=center >1</td>
</tr>
<tr>
<td>5.1 Channel PCI Surround-Sound Card</td>
<td>11000975</td>
<td align=center >1</td>
</tr>
</table>
In short, all basic programming constructs can be used in VTL. Loops can be done using #foreach, conditional statements can be done using #if-else.
For more information on nVelocity please visit nVelocity Home Page.