Velocity Code in Emails and Logic Steps
The scripting engine behind auto responder email templates and logic steps is Apache Velocity. It's a Java based scripting engine that runs well within the UltraCart system.
There is a learning curve associated with velocity, but it's also very powerful and fast.
Logic Step Introduction
The goal of the code is to instruct the autoresponder which step to run next.
This is done by setting the $result
variable (string value) to the name of a step directly following this logic step.
The links above will help you determine which step to use based on the customer and their history.
The simplest valid logic block would be a single assignment to $result
:
#set($result = 'Name of Child Step')
Here's another example:
#if($customer.orders.size() > 0) #set($result = 'Existing Customer Step') #else #set($result = 'New Customer Step') #end
To debug your code, use the $logger.log('some message here')
method:
$logger.log('Customer Email') $logger.log($customer.email)
To end a campaign successfully within a logic step, do the following:
#set($result = '_ENDCAMPAIGN_')
Requirements
For Email Templates: any valid velocity syntax will do, and is totally optional
For Logic Steps: 1) valid velocity syntax and 2) must #set the variable $result to the name of child step.
References
Apache Velocity Homepage: http://velocity.apache.org/
User Guide: http://velocity.apache.org/engine/releases/velocity-1.6.2/user-guide.html
Reference Guide: http://velocity.apache.org/engine/releases/velocity-1.6.2/vtl-reference-guide.html