...
Tip |
---|
This velocity code is for Auto Responder Logic blocks. The $customer object is not available in email notification templates such as receipts. |
If this customer has placed an order before,
...
execute the 'Existing Customer'
...
step otherwise, execute the 'New Customer' step.
Code Block | ||
---|---|---|
| ||
#if($customer.orders.size() > 0) |
...
#set($result = 'Existing Customer') |
...
#else #set($result = 'New Customer') |
...
#end |
...
Check all of the customers orders
...
. if they have ordered the key product, send the 'Upsell' email
...
. If they have ordered other product, send them a 10% off coupon
...
. If they have never ordered, send them a 20% off coupon.
Code Block | ||
---|---|---|
| ||
#set($found_key_product = false) |
...
#if($customer.orders.size() > 0) |
...
#foreach($order in $customer.orders) |
...
#foreach($item in $order.items) |
...
#if($item.itemId = 'TSHIRT') |
...
$set($found_key_product = true) |
...
#end #end #end #if($found_key_product) |
...
#set($result = 'Upsell') |
...
#else ## customer has ordered, but not a key product. offer 10% |
...
coupon #set($result = '10% Off Coupon') |
...
#end
#else ## customer has not ordered. offer 20% coupont
#set($result = '20% Off Coupon')
#end |