Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Purpose

The purpose of this campaign is to send out coupons every Sunday night to customers who have ordered in the past week.

Step Layout

These are the steps laid out for you. The logic steps are detailed below.



IsSundayNight? Logic

This logic step does a simple check to see if the current time is between 6 PM and Midnight on a Sunday night.

#if( $dateManager.isCurrentTimeBetween("Sun", "18:00", "Sun", "23:59"))
   #set( $result = 'OrderedInLast8Days?' )
#else
   #set( $result = 'Pause1Hour' )
#end

OrderedInLast8Days?

$logger.log($customer.orders.size())
#set( $hasOrdered = false )

#set( $sevenDaysAgo = $dateManager.currentTime())
$sevenDaysAgo.add("day", \-7)
$logger.log($sevenDaysAgo.format("MM/dd/yyyy"))

#foreach( $order in $customer.orders )
   $logger.log($order.orderId)
   $logger.log($order.paymentDate.time)

   #if($order.paymentDate.time > $sevenDaysAgo.timeInMillis)
      $logger.log('order was within 8 days')
      #set( $hasOrdered = true )
   #else
      $logger.log('order was NOT within 8 days')
   #end
#end

#if($customer.hasPurchasedInLastDays(8))
   #set( $result = 'DidOrder' )
#else
   #set( $result = 'DidNotOrder' )
#end




Discussion

The code block above makes liberal use of the $logger.log() function. This will print out any velocity object. This is an invaluable tool for developing logic blocks. It won't hurt to keep it in place for production runs.

Goto Logic Blocks

#set( $result = '_GOTO_:IsItSundayNight?' )


The goto blocks are nothing more than a simple GOTO directive back tot he IsItSundayNight? logic step.

  • No labels