Thank you email with product descriptions (Campaign Cookbook)

Requirement

From a support email we received:

Hello Ultracart,

I want to send a customer a thank you e-mail.
What is the velocity code to list the product descriptions of what they just bought in the e-mail?

I also want to send a re-order e-mail a few months later.
Is it possible to put with the velocity code any of the product names that they ordered in the e-mail title?

Plan

  1. Create a campaign.
  2. Create your two emails.
  3. Create your campaign steps.
    1. Thank you email step
    2. Pause step
    3. Re-order email

This tutorial focuses on using UltraCart velocity objects.
The object reference page is a great page to have open while working through this tutorial.

Implementation

Campaign Creation

Here's the campaign I've created. Note the enrollment trigger. That's the key to having this fire after product is orders.
I've added a product filter that will only fire this campaign for a ProductX is orders. If you wish to fire it for every product, leave the Enrollment Items blank.



Email Templates

The main requirement for the email templates is product information. So we'll focus on that.

Enroll someone (preferably you), with prior purchases from your store, into your campaign. You can then use that email address to test out your emails. This is critical to success when working with velocity and order history inside email templates.



Here's the settings I've used for the thank you email.



For the html message, I used the following combination of html and velocity. There's no css or formatting to keep the code below relevant.

<html><body>
$customer.displayName<br />
Thank you for your recent purchase from MYSTORE.<br />
<br />
Items<br />
#set($lastOrder = $customer.lastOrder)
#foreach($orderItem in $lastOrder.items)
   $logger.log($orderItem.itemId)
   #set($item = $group.getItem($orderItem.itemId))
<table>
<tr>
   <td>Product:</td>
   <td>$item.getDescription()</td>
</tr>
<tr>
   <td>&nbsp;</td>
   <td>$item.getExtendedDescription()</td>
</tr>
</table>
<br />
#end
*|OPT_OUT|*
</body></html>

To test it out, I registered our infamous test@test.com customer, whose last purchase from us was a sci-fi book. After validating, this is the output on the preview tab.



The second email, a follow up to order, will be whatever you wish. The only issue you might encounter is constructing the buy link for the product. You could hard code the link if there was only a single product, but if you are wanting the customer to re-order the same product they bought, and this email campaign is going out for all products, then you'll need some more velocity. The following html/velocity does that.

<html>
<body>
<style type='text/css'>td{padding:5px}</style>
$customer.displayName<br />
Thank you for your recent purchase from MYSTORE.<br />
It's time to reorder!<br />
You may use the links below to reorder.<br />
<br />
Purchased Items<br />
#set($lastOrder = $customer.lastOrder)
#foreach($orderItem in $lastOrder.items)
   $logger.log($orderItem.itemId)
   #set($item = $group.getItem($orderItem.itemId))
<table>
<tr>
   <td>Product:</td>
   <td>$item.getDescription()</td>
   <td>
     <a target='_blank' href='http://secure.ultracart.com/cgi-bin/UCEditor?merchantId=DEMO&ADD=$item.getMerchantItemID()'>Re-order Page</a>
   </td>
</tr>
</table>
<br />
#end
*|OPT_OUT|*
</body></html>



Result:



Campaign Steps

Okay, with email templates in hand, I return to editing my campaign and scroll down to the bottom where the steps are located.
Initially, I just have my start step. I need 3 more steps. I click the Add Step button, and add my first email step.



Next, the Pause step.



Finally, the second email step.



Here's all 4 steps.



And with that, my campaign is finished and ready for testing with some dummy orders.
Cheers!