UltraCart Objects available to Auto Responder Scripts
AutoResponder Object Reference
The Autoresponder campaigns use the same velocity engine as the UltraCart Catalogs.
Please see the online context and object documentation at
UltraCart Velocity Documentation
Logic Steps
Logic steps run velocity code. The following is a list of top level objects made available to a logic step during execution:
Variable | Description |
---|---|
$result | This is what you set to determine the next step. Once you're finished with your logic, at some point, you should be doing something like this: |
$logger | Useful for logging during logic steps to find out why your code isn't working. Try |
$customer | The most important object. See the docs below on the $customer object and how you can use it to make a logical decision (i.e. find order history, etc.) |
$coupon | Used to generate coupon codes to embed in emails. Although available to the logic step, its doubtful you'll ever use it here. |
$giftCertificateManager | Used to generate gift certificates in emails. Although available to the logic step, its doubtful you'll ever use it here. |
$dateManager | A utility to format and handle dates |
This is a catalog object, and technically out of place here since a logic step has no item groups. However the group object has many utility functions for retrieving item information. So it's included in the logic toolset. See the catalog docs above for the |
Email Templates
Email templates also run velocity code. The following is a list of top level objects made available to an email template during execution:
Variable | Description |
---|---|
$logger | Useful for logging during template creation to find out why your email isn't showing what you want. Try |
$customer | The most important object. See the docs below on the $customer object and how you can use it to personalize an email. (i.e. find order history, etc.) |
$coupon | Used to generate coupon codes to embed in emails |
$giftCertificateManager | Used to generate gift certificates in emails |
A utility to format and handle dates | |
$group | This is a catalog object, and technically out of place here since a logic step has no item groups. However the group object has many utility functions for retrieving item information. So it's included in the logic toolset. See the catalog docs above for the |
Secondary Objects
The $group object provides access to many secondary objects. See the group docs for details about those objects.
Object | Description |
---|---|
CampaignHistory | Provides a list of steps the recipient has traveled. This might be useful to determine the path the recipient has taken. |
Contains order details. This object is returned from several |
Object Reference
$result
Discussion: $result is used by logic steps to determine which branch to take. The object begins as an empty string and is #set
by you during a logic step.
$logger
Discussion: $logger is a helpful tool for creating emails and logic steps.
Methods:
Method Name | Signature | Returns | Example |
---|---|---|---|
log |
| <nothing> |
|
$cart
Discussion:
The $cart object is ONLY available to campaigns enrolled via the return email hook.
Also, it is ONLY available within Email templates. Do not use the $cart object anywhere else (i.e. the Logic step).
Always check to make sure $cart is not null when you use it. It is most useful within an email template to embed a link. But it is also present in the logic steps in case you wish to direct your actions based on whether you have the return link or not. You configure how long an order remains before it is considered abandoned (Home → Configuration → Abandon Interval). The $cart object will be valid up until that time. After that time, it will be null.
Methods:
Method Name | Signature | Returns | Example |
---|---|---|---|
getReturnLink |
| a bitly url useful for directing a customer back to their checkout. |
|
getReturnLink | getReturnLink(String returnUrl, String tokenParameter)
| a bitly url useful for directing a customer back to their custom checkout. | #if("$!{cart}" != "") ## <--Â better way to check for nulls instead of #if($cart) Please complete your order! Here's a 20% off coupon that is good for the next 48 hours! Â #set($cCode = $coupon.generateCode('MY_20_OFF', '48')) Â $cart.addUniqueCouponCode($cCode) Â #set($returnLink = $cart.getReturnLink("www.myjavascriptcheckout.com/checkout.html", "returnCode")) <a href="${returnLink}">Your Order</a> Â #end |
addUniqueCouponCode |
| true if successful, else false. If false, $cart.getErrors() will contain a list of errors. | see getReturnLink for example |
setReturnUrl | alternative way to use custom return link | if you setReturnUrl and setTokenParameterName, then the getReturnLink() with empty parameters will also return a custom link. This is mainly going to be used with External Integrations such as Lyris. If you're not using Lyris, then getReturnLink(returnUrl, tokenName) is simpler and preferred. | |
setTokenParameterName | alternative way to use custom return link |
The above example uses the return link, and tacks on a coupon to the url, which will automatically apply it to the customer's cart.
$customer
Discussion: The $customer object holds basic information about a customer and has the ability to retrieve order history
Methods:
Method Name | Signature | Returns | Example |
---|---|---|---|
getCampaignHistory |
| a list of the recipient's history in this campaign |
|
getCountOfPurchasesInLastDays |
| a count of purchases made |
|
getCountOfShipmentsInLastDays |
| a count of shipments made |
|
getDisplayName |
| the name of the recipient, or if that wasn't collected, their email address | Welcome |
getDisplayFirstName | $customer.getDisplayFirstName() | the first name of the recipient, or if that wasn't collect an empty string | Welcome $customer.getDisplayFirstName() , here's a coupon... |
getDisplayLastName | $customer.getDisplayLastName() | the last name of the recipient, or if that wasn't collect an empty string | |
getEmail |
| them email address of the recipient | This email was address to: |
getEnrollmentDts | #set($timestamp = $customer.getEnrollmentDts()) | this returns back a Java Timestamp object. | |
getEnrollmentOrder |  #set($enrollmentOrder = $customer.getEnrollmentOrder() | returns the order that triggered enrollment. If enrollment was not based on a purchase, this will be a null value. | |
getEnrollmentOrderId | #set($orderId = $customer.getEnrollmentOrderId()) | ||
getEnrollmentSource | #set($source = $customer.getEnrollmentSource()) | returns a string showing what the enrollment source is. Possible values:
| |
getLastOrder |
| Retrieves the last order the customer made. You may wish to check if they've ordered anything first (hasPurchasedEver, etc) |
|
getOrderId | Â #set($orderId = $customer.getOrderId()) | returns the order id that triggered enrollment. Â If enrollment was not based on a purchase, this will be a null value. | |
getOrders |
| Retrieves a list of orders for the customer. |
|
getRecurringInformation |
| returns the customer's meta information related to the recurring order (also known as 'auto order' or trial order). Always call |
|
getTotalForAllOrders | $customer.getTotalForAllOrders() | Total dollars the customer has ever spent. Useful to check for spending thresholds This returns a BigDecimal object. | Note! the total is a BigDecimal object. use longValue() to get a primative number.
|
getTotalForAllPurchasesInLastDays |
| Same as above, but filters on purchases within the last XX days. This returns a BigDecimal object. |
|
getTotalForAllShipmentsInLastDays |
| Same as above, but filters on shipments within the last XX days. This returns a BigDecimal object. |
|
hasPricingTier | $customer.hasPricingTier("Wholesale") | returns true if the customer has an established customer profile in the UltraCart system and has the specified pricing tier. |
|
hasPurchasedEver |
| return true if the customer has ever purchased the item. |
|
hasPurchasedEver | $customer.hasPurchasedEver([itemId1, itemId2, itemId3]) | Same as above, but with a list. |
|
hasPurchasedInLastDays |
| Same as above, but with a days argument. |
|
hasPurchasedInLastDays |
| Same as above, but with a days argument. |
|
hasReviewedItem |
| returns true if the customer has already completed a review for the specified item. |
exit the 'please review this item campaign.
send the customer to an step sending them a reminder email
|
hasShipmentInLastDays |
| see similar 'purchased' method. Some merchants prefer shipment dates over purchase dates. |
|
hasShipmentInLastDays |
| see similar 'purchased' method. Some merchants prefer shipment dates over purchase dates. |
|
hasShipmentInLastDays |
| see similar 'purchased' method. Some merchants prefer shipment dates over purchase dates. |
|
isRecurring |
| returns true if the customer's underlying order was a recurring order (also known as 'auto order' or trial order). If this is true, then you may call |
|
lastOrderContains |
| checks to see if the last order contained a specific item. |
|
lastOrderContains |
| checks to see if the last order contains one of the items in the list |
|
$coupon
Discussion: The $coupon
object is only useful for email templates. It does one thing, and one thing only. It generates a unique coupon code for an email. To use, you must first set up a coupon code using the merchant portal. Login to UltraCart an navigate to Home → Marketing → Coupons to create a coupon that you may use.
Method Name | Signature | Returns | Example |
---|---|---|---|
generateCode | $coupon.generateCode('COUPONID', 'hoursToLive') | generates a unique coupon code based on the coupon id/code |
|
hoursToLive is a STRING. It has to be a valid number, but it's passed in as a string. Be sure to surround it with double or single quotes. If you don't, it will not work.
$externalAutoresponderFactory
Discussion: The $externalAutoresponderFactory allows the merchant to load a specific external autoresponder to use within their logic step. This allows the merchant to use the tremendous flexibility of the autoresponder rules engine, but cause emails to send through an external auto response.
At this time only LyrisHQ is supported.
Methods:
Method Name | Signature | Returns | Example |
---|---|---|---|
getExternalAutoresponder |
| An implementation of that particular external autoresponder. |
|
The above example obtains the LyrisHQ external autoresponder object.
$externalAutoresponder
Discussion: The $externalAutoresponder performs the communication with the external autoresponder system such as LyrisHQ.
Methods:
Method Name | Signature | Returns | Example |
---|---|---|---|
subscribeReturnEmail |
| true/false if subscription successful |
|
$giftCertificateManager
Discussion: The giftCerticateManager provides the means to create gift certificates, add/subtract balances from them, and print out the code and balance of them.
Most methods return a GiftCerticate
, which is a simple object with two methods: getRemainingBalance()
and getCode()
. You'll see the GiftCertificate
object used in the examples below.
Note: All gift certificates created are tied to the campaign recipients email address.
Method Name | Signature | Returns | Example |
---|---|---|---|
generate | generate(amount) | creates a gift certificate for a certain amount | Dear |
generate | generate(amount, addToExisting) | same as above, but will see if the recipient already has an existing gift certificate and add to that amount, else a new certificate is created. | |
generate | generate(amount, addToExisting, expirationDays) | same as above, but will see if the recipient already has an existing gift certificate and add to that amount, else a new certificate is created. The certificate will expire in the given days provided. | |
generate | generate(amount, expirationDays) | creates a gift certificate for a certain amount that expires in a certain amount of days |
CampaignHistory
Discussion: You may get a list of history objects from $customer.getCampaignHistory
. From this, you may loop through the list and see what the customer has done.
There are no methods to this object, only properties.
Property | Discussion |
---|---|
stepName | The name of the campaign step. |
stepResult | the result of the step. will almost always be 'success', else the campaign would've ended and you wouldn't be running logic against the recipient. |
timeStamp | when the step happened |
RecurringInformation
Discussion: You may get an object contains recurring, or auto order information by calling $customer.getRecurringInformation()
. Listed below are the properties of that object.
Property | Data Type | May be Null (Empty)? | Discussion |
---|---|---|---|
orderId | NO | The Order ID | |
enabled | boolean | Not Possible | if false, this recurring order is dead/ended |
autoOrderCode | NO | The unique code associated with this recurring order | |
creditCardAttempt | int | Not Possible | The number of attempts to charge a card. If non-zero, then billing has failed at least one time (see failure reason for why) |
nextAttempt | YES | The date when the next charge attempt will happen | |
items | Collection of RecurringItems | NO | A collection of recurring items. See |
cancelledByUser | YES | If cancelled, this field will contain the person who handled the cancellation. | |
cancelledDts | YES | If cancelled, this will be the datetime when of cancellation. | |
cancelAfterNextXOrders | Integer | YES | If not null, this is the number of orders before cancellation. |
failureReason | YES | If not null, provides insight into why a recurring order failed. Do not program logic based on this field. UltraCart reserves the right to change this field's contents at whim. | |
disabledDts | YES | If disabled, this is the datetime when the order was disabled/ended. |
RecurringItem
Discussion: You may get an object contains recurring, or auto order information by calling $customer.getRecurringInformation()
. Listed below are the properties of that object.
Property | Data Type | May be Null (Empty)? | Discussion |
---|---|---|---|
nextShipment | YES | datetime of the next shipment | |
frequency | NO | a string showing the order frequency. do not code logic against these values. they may change. | |
remainingRepeatCount | Integer | YES | the number of orders left |
lifeTimeValue | YES | The sales amount so far. | |
numberOfRebills | int | NO | The number of rebills done for this item. |
rebillValue | YES | The amount of rebills done for this item. | |
lastOrderDts | YES | datetime of the last order | |
noOrderAfter | YES | datetime of when no more orders will happen | |
arbitraryUnitCost | YES | If merchant has done an override, this is the new unit cost. | |
arbitraryItemId | YES | If merchant has done an override, this is the new item id. | |
arbitraryQuantity | YES | If merchant has done an override, this is the new quantity. | |
arbitraryUnitCostRemainingOrders | Integer | YES | If merchant has done an override, this is the new remaining orders. |
originalItemId | YES | If merchant has done an override, this is the original item id. | |
originalQuantity | YES | If merchant has done an override, this is the original quantity. | |
arbitraryScheduleDays | Integer | YES | If merchant has done an override, this is the new schedule. |
arbitraryPercentageDiscount | YES | If merchant has done an override, this is the new discount. |