Exemple de code pour l'exemple 2

L’exemple de code est le script avancé pour l’exemple 2.

Dans l’exemple 2, le script teste le contenu d'une table de dimension, établit le type de compte du destinataire, affiche l’historique des achats, présente des options d’achat supplémentaires en fonction du type de compte et offre des mises à niveau de compte après le test d’éligibilité.

<UAEscript>
<declarePF names="CustomerFN, AccountType,NewCustomer,CustTransact.PurchaseDate,
CustTransact.PurchaseAmount,CustTransact.TwelveMonthPurchases,
CustTransact.PointsEarned,CustPrefProd.ItemID,CustPrefProd.ItemDescription"/>

<!--scriptBody>
    <@if (deliverDimensions.CustTransact?size >0)>
        <p>        
        <@if (AccountType="silver")>As a Silver member, during our 
Summertime Splash program every time you spend between $100 and $500 
you earn 100 bonus points. Spend more than $500 and you earn 200 points. 
Look below to see the rewards you have already earned this month.
        
        <@elseif (AccountType="gold")>As a Gold member, during our 
Summertime Splash program you earn at least 100 bonus points every time 
you buy. Spend between $100 and $500 and you'll earn 250 points. Spend 
over $500 and we'll double your points - a total of 500 points for every 
purchase of $500 or more.Look below to see the rewards you have already 
earned this month.

        <@elseif (AccountType="platinum")>As a Platinum member, 
during our Summertime Splash program you earn at least 200 bonus points 
every time you buy. Spend between $100 and $500 and you'll earn 500 points. 
Spend over $500 and we'll double your points - a total of 1000 points 
for every purchase of $500 or more. Look below to see the rewards you 
have already earned this month.
        </@if>    
        </p>
    </@if>

    <table>
        <tr>
            <th>Purchase Date</th>
            <th>How much you paid</th>
            <th>Reward points you earned</th>
        </tr>
<@list dimension="CustTransact" sortBy="TransactionID:numeric:descending";row>
        <tr>
            <td>
                ${row.PurchaseDate}
            </td>
            <td>
    ${row.PurchaseAmount}
            </td>
            <td>
    ${row.PointsEarned}
            </td>
         </tr>
</@list>
    </table>

    <@if (AccountType = "platinum")><p>Check out 
<a href=http://www.example.com/newProducts?prodID=123>the latest 
product that we've reserved for our Platinum members.</a> 
Because you are a Platinum member, we'll ship it for free!</p>

            <@elseif (AccountType != "platinum" && 
(custTransact.TwelveMonthPurchases?number >5000))><p>
This purchase makes you eligible for Platinum member status! Click 
<a href="http://www.example.com/upgrade2Platinum>
Tell me more</a> to learn how you can take yourself to 
a higher level.</p>

            <@elseif (AccountType = "gold")><p>Check out 
<a href=http://www.example.com/newProducts?prodID=456>the latest 
product that we've reserved for our Gold members.</a> Enjoy a 50% 
discount on shipping because you are a Gold member!</p>

            <@elseif (AccountType = "silver")><p>Check out 
<a href=http://www.example.com/newProducts?prodID=789>the latest 
product that we've reserved for our Silver members.</a> 
Order now and we'll ship direct to you within 3 days.</p>

            @elseif (AccountType = "silver" && custTransact.TwelveMonthPurchases?
number >1000 && custTransact.TwelveMonthPurchases?number <5000)>
<p>This purchase makes you eligible for Gold member status! 
Click <a href="http://www.example.com/upgrade2Gold>
Tell me more</a> to learn how you can take yourself to 
a higher level.</p>
            </@if>
        

        <@if (deliverDimensions.CustTransact?size <1 && NewCustomer?number =0>
<p>We haven't heard from you for a while. You might be missing out 
on some of the greatest deals we've ever had. Here is a sample 
of what's new.</p>

    <table>
        <@list dimension="CustPrefProd" sortby="PreferenceRank:numeric:descending" 
maxRows=3; row>
           <tr>
               <td><a href="http://example.com/newProducts?prodID=${row.ItemID}">$
{row.ItemDescription}</a></td>
           </tr>
            </@list>
      </table>

     <p> Check out all of our new items 
<a href="http://www.example.com/latest>here</a>.<p>
     <p>To provide a bit more encouragement ${CustomerFN}, 
we'll give you 100 rewards points with your next purchase. 
We hope to hear from you soon!</p>
        </@if>

        <@if (NewCustomer?number =1)><p>Because you 
are a new member, we will give you an additional 150 reward points for 
every purchase you make this month.
Just our way of saying thanks for choosing us, ${CustomerFN}.</p >
        </@if>

</scriptBody-->

Summer Splash Promo 2

</UAEscript>