User Tools

Site Tools


en:redeeming_coupons

This is an old revision of the document!


Redeeming Coupons

When a coupon number is typed or a coupon QR Tag scanned, SambaPOS will find related coupon entity and assign it to the ticket. That will automatically create a gift order for the product associated with coupon. As ticket submitted we’ll mark coupon as Redeemed to prevent multiple uses of coupons.

We’ll also solve another security issue by updating coupon redeem status as In Ticket as soon as it scanned. So multiple scans will not generate multiple gift lines. In fact we can do the same thing by directly updating coupon status as redeemed but we want to allow operators to cancel a coupon scan before submitting it.

Finding Coupons

We need an action to find and assign coupons to ticket. Since coupons are entities we can use “Change Ticket Entity” action to assign a coupon to the ticket.

Can Create Ticket parameter is useful for Fast Food screens. If there is no active ticket displayed when this action is called it creates a new ticket. While using this action we’ll generally find entities by their name. We can use both Entity Search Value or Entity Name parameters but they have different effects. Searching by Entity Name will retrieve entity from cache so you won’t have latest changes on entity data. It is useful to load rarely changing entities like Tables. Since we always need updated entity data we’ll use Entity Search Value.

We’ll use number pad editor to type or scan coupon numbers. When we enter a number there Number Pad Value Entered Event executes so we can create a rule for that event to read which coupon is scanned.

We can read scanned numbers with “NumberpadValue” parameter but at first we should check if it is a valid coupon code. We’ll create two custom constraints to check if scanned number starts with CP prefix and length equals to 11 digits. Notice how we changed Execute If setting to Matches All to force rule to validate all constraints. Don’t forget adding default mapping before saving the rule.

Now when we scan a valid coupon number it should create a new ticket with Coupon number displayed on header.

On previous chapter we’ve created a Coupon numbered as CP8GS-DZC-38S. We’ll type it manually for testing if our rule works or not. Normally we’ll scan it from a barcode or QR Tag.

This is a Fast Food screen so there is no active ticket. Change Ticket Entity action should create a ticket before assigning coupon to the ticket. Now you can hit Enter.

New ticket created with Coupon Number displayed on header. That means our action and rule works fine.

Don’t worry if Coupon number not appeared on header. Because of an optimization to avoid unnecessary refreshes sometimes that happens. We can execute “Display Ticket” action to force itself to refresh but on next steps we’ll copy coupon number to order line and remove it from ticket header. So it is not needed. If you want to see updated header just add an order and cancel it.

Close this ticket without adding any item in it. On next step we’ll create another action to add Free Coffee into Ticket when a coupon scanned.

Adding Free Products Into Ticket

We can use Add Order action to add orders into a ticket.

Menu Item Name parameter contains a variable called [:Product Name]. We’ll assign this value from Coupon. We’ll also update GStatus state as free. GStatus is an internal order state group for Gift and Void states. Instead of marking it as Gift we’ll mark it as Free so Gift and Cancel Gift buttons will not work for this order. Decrease Inventory parameter is True so it will decrease our inventory. Calculate Price parameter is False so this order will display the price but won’t change ticket total like Gift orders.

You can consider enabling Locked parameter to disable canceling this order. For this tutorial we’ll permit canceling coupon orders before submitting.

We’ll create a rule for “Ticket Entity Changed” event to execute this action when a Coupon scanned.

When any ticket entity changes “Ticket Entity Changed” event fires. First we need to create constraints to be able to understand selected entity is a Coupon. So Entity Type Name should be Coupons and New Entity Name should be anything different than *. This is a change event so it executes when we remove Entities form ticket. If entity name equals * that means Coupon Removed from ticket.

We won’t execute Add Gift Order action if coupon is already redeemed. So on third line of the constraint we are checking Redeem status.

If selected entity is a Coupon we’ll execute “Add Gift Order” action. We’ll read product name from Coupon’s Menu Item Name with {ENTITY DATA:Coupon:Menu Item Name} tag.

Now let’s test again what will happen when we enter a coupon code.

That worked fine. When we scan a coupon number it adds a free coffee into the ticket.

On next step we have to solve another issue. We’re displaying coupon number on ticket header but we’ll loose this information when we scan another coupon. You can forbid multiple coupons on a single ticket but for this example we’ll allow it. To be able to support multiple coupons on a single ticket we need to store coupon numbers on order lines.

en/redeeming_coupons.1379263592.txt.gz · Last modified: 2013/09/16 00:46 (external edit)