Review Item Auto Responder Tutorial

Requirement

From a support email we received:

For example:
1. Customer purchases our #647 canvas tent at the following link:  http://www.camptents.com/shop/canvas-tent/
2. We would like to have the autoresponder send an email to them in say 10 days asking for a review of the #647
3. Item ID is 647
4. Catalog page: http://www.camptents.com/shop/canvas-tent/
5. Review page is on the same page as the item catalog page as a tab:  http://www.camptents.com/shop/canvas-tent/

This is an example but we would like the link in the email to dynamically display the link to the catalog page for the product(s) that  they purchased. Hope this helps. Let me know if I can explain further. 
Thanks again for helping us with this. We very much appreciate your 
support.

Plan

Here's a quick summary of the process

  1. Create an email template
  2. Create a campaign
  3. Create your campaign steps.
    1. Pause: 10 days
    2. Logic: any items not yet reviewed?
    3. Email: Send 'please review' 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.

Estimated Time: 20 minutes (plus time to create a beautiful html email).

Implementation

Email Template

Give the template a name, subject, and format.

Create the html.  An example below is provided with heavy comments.

We'll leave it to you to make the email pretty and enticing.

 

#* @vtlvariable name="formatHelper" type="com.bpsinfo.ultracart.catalog.tobjects.FormatHelper" *#
#* @vtlvariable name="group" type="com.bpsinfo.ultracart.catalog.tobjects.GroupImpl" *#
#* @vtlvariable name="customer" type="com.bpsinfo.ultracart.autoresponder.tobjects.Customer" *#
## You may ignore the comments above.  They're editor hints for Intellij, an amazing editor
 

<!DOCTYPE html>
<html>
<body>
Hey. Please take a minute and review each item in your recent purchase. Thanks!
<table>
 

## the enrollment order had better exist if this email is being called in a campaign.
  #set($order = $customer.getEnrollmentOrder())
  #foreach($orderItem in $order.items)
  ## notice that orderItem and item are different.  orderItem contains a skeleton item and order-specific information
  ## item retrieved from the $group object has the full array of item information, like the view url, etc.
  ## $group is a provided variable.  It's named 'group' because it's also used in the store catalogs for group pages (pages that display a group of items)
    #set($item = $group.getItem($orderItem.getItemId()))
    #set($reviewed = $customer.hasReviewedItem($item.getMerchantItemID()))
    <tr>
      <td>
        <a target="_blank" href="$item.getViewURL()">$item.getDescription()</a>
      </td>
      <td>

        #if($reviewed)
          Reviewed. Thank you!
        #else
          ## the url below is secure.ultracart.com.  just leave it like that.  The url will do a redirect if you're using a custom SSL.
          ## This should be the starting pointing for review links.
          <a target="_blank"
             href="https://secure.ultracart.com/cgi-bin/UCReviewItem?merchantId=${customer.getMerchantId()}&itemId=${orderItem.getItemId()}">Write
            Review</a>
        #end ##if-reviewed

      </td>
    </tr>
  #end ##foreach-item in order
 

</table>
*|OPT_OUT|*
</body>
</html>

 

Campaign

For the campaign, use an enrollment trigger of 'Purchased Product'.  

 

 

Campaign Steps

Save your campaign, and then scroll down to the steps.  You'll need four steps.  While the process appears linear (no branching), the Logic step does contain an _ENDCAMPAIGN_ result, which is essentially a branch in that it marks a recipient as finished at that step.

The Start step is created for you.

The Pause step can be set to whatever time delay you desire.

The Logic step is the complex step in the process.  It checks the customer's enrollment order to see if all the items have been reviewed.  If so, the customer (recipient) is marked finished in the campaign and goes no further.  If there are still items to review, the recipient is moved on to the EmailReview step, which sends them a reminder email.

#* @vtlvariable name="customer" type="com.bpsinfo.ultracart.autoresponder.tobjects.Customer" *#
## You may ignore the comments above.  They're editor hints for Intellij, an amazing editor
 

## the default result of this logic step is a step called 'EmailReview'
## go through the enrollment order (the order that triggered enrollment)
## and look at each item ordered.  If the customer has not yet reviewed
## an item, set the $hasReviewsToDo variable to true
## At the end of the check, if $hasReviewsToDo is false, exit the campaign
## since we don't want to spam them with reminders for things they've already done.
#set($result = 'EmailReview')
#set($hasReviewsToDo = false)
 

#set($order = $customer.getEnrollmentOrder())

## the line below is the best way to check for a null value, or in this case, to check that a value is NOT null
## the line below converts the object to a string and compares it to an empty string.  A null object will
## translate to an empty string when referenced with the $! (dollar sign + exclamation mark)
#if("$!order" != "")

  #foreach($orderItem in $order.items)
    #if($customer.hasReviewedItem($orderItem.getItemId()))
      #set($hasReviewsToDo = true)
    #end ##if-customer has reviewed item
  #end ## foreach-item in enrollment order

#end ## if-enrollment order exists
## note above the comments after each #end.  velocity is awesome.  (true story), but it uses #end for every logic block.
## so a good practice is to label each and every #end with a description.  It pays off in the long run.  Huge payoff.
 

## notice the exclamation sign below for "NOT"
## if the customer does NOT have reviews to do, exit the campaign.
#if(!$hasReviewsToDo)
  #set($result = "_ENDCAMPAIGN_")
#end

 

The email step is straightforward.  Just select the email template you created above.

 

That's it.  Most of your time will be spent creating a beautiful email template.