Day 3 – Provide different offers based on locations

Challenge

https://ampscript30.com/ampscript-challenge-day3/

To offer different discounts based on where customers locate.

Solution

Dear %%=ProperCase(FirstName)=%%,

We are excited to offer you a special deal on our product. Today only, you can receive the following offer:
%%[
set @city = city
IF @city == 'Halifax' THEN
    set @msg = 'Free shipping on all local orders in Halifax!'
ELSE
    set @msg = 'Free shipping discount code FREESHIPPING!'
ENDIF
]%%
%%=v(@msg)=%%

Preview

Summary

IF/THEN statement allows the conditional execution of any content within the IF block depending on the logic expressions it contains. If there are only two conditions, IIF(condition, value to return if condition is true, value to return if condition is false) can be used as an alternative.