Hello. In this tutorial I’ll show you how to create points based promotions.
- Upgrade to at least 4.1.27 version before starting this tutorial.
- If you have Database Tools Module you can simply use this import file for easily importing this configuration to your database. Points_Promotion.zip (1.6 KB) Please test it first on a safe environment before merging it to your production database.
- For the simplicity of this tutorial I’ve skipped Rule Mapping steps. After creating each rule, create a default mapping by adding a mapping line and leaving it unchanged.
##Earning Points
First we’ll start by creating a custom product tag. This tag will be named as Points
After saving it I can edit products and set promotion points. We’ll give free Coffee for 6 points.
… and free Juice for 8 points.
I’ll create a custom field for Customers
to store their points. To be able to do this I’ll add a custom field.
I need an action to increase customer points. I’ll use Update Entity Data
action for this.
… and another one to decrease points.
I need to change promotion product’s order state to track from which products customer can earn points. I’ll use Update Order State
action to mark an order so when ticket gets paid we’ll increase customers points by using this information.
We’ll use Order Added to Ticket
rule to check product’s promotion points and if it is greater than 0 and if a customer is selected we’ll change order’s promotion state. We are using two step here because we won’t increase Customer Points immediately as order added to ticket. We’ll do it when ticket gets paid.
When ticket gets paid I’ll change promotion orders state from Points
to Earned
. I’m using Ticket Payment Check
rule for this. So every orders that have Points state changes to Earned and we’ll update customer points.
When an order’s state becomes Earned
, Order State Changed
event fires. I can handle it with a rule to increase customer points.
For every Coffee or Juice customer buys she’ll earn 1 point.
Let’s sell 2 Coffee and 1 Juice to a customer and check how Points data changes.
Coffee and Juice state changes. Herbal Tea does not change since it is not included.
When I settle this ticket customer points increases to 3 as shown here. Every promotion products we sell increases points by 1.
##Using Points
On the next step I’ll create actions for giving free items.
I’ll start by creating an Automation Command
for Use Points
button.
I’ll map this command to Order Lines that have Points
state.
Notice how I’m mapping this button to Order Line
and make it visible for promotion orders by changing Visible State
value to Points
.
I’ll create two rules to handle this button. If customer points is less then promotion points we’ll display a warning. If customer have enough points we’ll gift that item.
Before creating rules I’ll create an action to display messages.
First rule will check if customer have enough points.
[={QUANTITY}*{ITEM TAG:Points}]
is a custom expression to multiply product promotion points with order quantity. If Customer wants to use her points for 2 free coffee she need to have 12 points since a single Coffee needs 6 points.
We’ll create another rule to apply points. This rule is a little crowded so I’ll add separate screenshots to show all action parameters.
First action will decrease Customer Points
I’m using same custom expression to calculate exact points if order quantity is more than 1.
Second action will change order to a free order. Nothing special here. We only need to change Decrease
value to True and Calculate Price
to False.
Third action will change order’s Gift
state to Promotion
. Since we immediately decrease customer points we need this operation to disable Cancel Gift
command.
Final action will clear order’s promotion state. We’ll just leave all values empty.
Let’s see how it works.
If you remember Jane White
already have 3 points. We’ll add one coffee and click Use Points
button.
We can’t give free coffee since we need at least 6 points. If I sell more coffee to increase points and try to use this function it should change order to a gift.