Automatic discount based on customer discount-level with set amounts per product

I’m wondering why you are using two different features together? I think your solution is awesome however it can be easier to manage if you use either price def.s or discounts for both happy hour and VIP discount implementation. I’m asking it to understand if it is a business requirement or something in SambaPOS forces you to do so…

Yes, Ok, I understand. Thanks for the detailed explanation @emre… I’m sure it will help other people to have a better understanding of Tags and their availability, Terminal Settings, and Program Settings! :slight_smile:

Yes. I thought a little detail about that might help someone else.

Basically, in my case, Happy Hour Price Definition gives exactly the same discount value (-10) to all people, not just VIP customers (my “regulars”). Implementing the VIP discount has allowed me to do away with a Menu Category that I had called VIP which contained select products at reduced prices.

During testing, what I realized was that if HH was in effect, the price was discounted by 10 by HH Tag, and again discounted by 10 due to VIP Discounting, resulting in a discount of 20, which is not what I want… so I had to remove VIP Discount if we were in the middle of Happy Hour.


As far as having a Trigger and an Automation Command available to control Price Definitions, I did that because it gives me more concrete control. I’m not sure if my Triggers are not set properly, but I have seen on many occasions that the Trigger gets missed somehow - that is, HH doesn’t get turned on when it should. Maybe you can see something wrong here …

I think we can review the way we’re handling happy hour. Maintaining a system wide (department) setting and updating prices accordingly is a legacy feature coming from V2.

We have Date based comparison features in rules so we can do same thing without using triggers or knowing if hh is active or not. When an order added we can test if current time is inside a specified range and execute update price actions or not. {DATE:XXX} tag will help a lot.

Not a bad idea @emre… just trying to wrap my head around a good way to handle that.

I mean, Price Definitions are a simple and effective way to define pricing for select products via a Tag, so I’m not sure we would want to stray from that, but I’m fairly certain that is not what you’re getting at. Instead, you are talking about foregoing Trigger usage, and performing checks during Order Added to Ticket, correct?

Please remind me, what kind of data can we get from {DATE:XXX}? Can we extract Day of Week?

For example, my Happy Hour runs as follows:

Monday, Tuesday (MT): 1500-1700
Wednesday, Thursday, Friday (WTF): 1600-1900
Saturday, Sunday (SS): none

Then, we want to combine that with checks for VIP Discount, so that we are not applying 2 Discounts at the same time.

EDIT: ok I found {DATE:X} formatting… what a PITA that was to find for some reason (searching for {DATE:X} returns no results whatsoever - must be a Forum thing).

EDIT2: Now that I think of it more, we wouldn’t need Price Definitions at all. Just another Custom Product Tag instead (named HH) … correct?

Is this what you’re thinking?

Yes it is what I’m thinking.

We should change execution rule to Matches All and also decrease weekday check to a single constraint as {DATE:ddd} Matches Mon|Tue.

This is not a general recommendation for everyone but as you’ve already have a product based discount implementation you don’t need price definitions for hh implementation.

PS: I think something conflicts with :X so {DATE X} search returns better results.

PS2: We might not need TN function for {DATE:HHmm} as greater/less comparisons already tries to convert left part to a number. TN is still useful for greater/less comparisons if left part is a formatted number that might have regional decimals or thousand separators.

1 Like

Thanks for that @emre - I didn’t know we could use an OR operator there.

I think you’re correct. I was having trouble getting the Rule to fire, so I thought it might need TN(), but it turned out that it wasn’t working because I needed to use {DATE:ddd} Matches Mon instead of {DATE:ddd} Equals Mon.

That might be a casing issue but Matches will work better as it makes a regex match. That’s why we can use | operator.

@emre, I’m noticing something strange with States. For example, when I update Ticket State to “Active”, a rule fires to update Order State, and the Order State is being set the same as the Ticket State, which I do not want.

In this message, I am displaying:

TS:{TICKET STATE:VIP}
OS:'{ORDER STATE:DiscountType}'

The Ticket State is correct with “Active”, but the Order State is showing the same value - instead it should be displaying HH or VIP…

Is it a bug? Let me test that. Can you PM me a backup?

I figured it out.

In the Actions to update Ticket State and Order State, I was using a variable named [:State], which I assume is Reserved. I’ve changed the action variables to [:TState] and [:OState], respectively, and it is behaving normally now.

1 Like

@emre, any chance we can get access to Order State and/or Order Tag inside Ticket State Changed Event?

I store either VIP or HH inside {ORDER STATE:DiscountType}.
When Ticket Entity is removed or changed (non-VIP), the Ticket State is updated to null or InActive, and it fires Actions to update Order State. I’m trying to prevent the removal of an HH Order State, and/or the replacement of an HH Order State with a VIP Order State.
As I watch the cycling through the past Orders, I realized that neither {ORDER STATE:DiscountType} nor {ORDER TAG:HH Discount} are available in the Ticket State Changed Event.

Umm @QMcKay I think I understand how it comes to that point. Unfortunately we can’t access {ORDER STATE} from Ticket State Changed event as that event is ticket related and we can’t determine which order’s state we need. Instead we need to access {TICKET STATE} from Order State Changed event. I feel there might be a issue here as we have some weird cases that needs to be handled. For example

  • Ticket started as anonymous and a customer assigned after hh ends.
  • Customer assigned before hh period and hh started.
  • Customer changed / assigned inside hh and some orders created before hh.
  • … etc.

If we elaborate such cases we can find the best method to implement both HH and VIP discounts.

1 Like

Yeah, thanks for that @emre. I spent all day working on this yesterday, and at the end, without thinking about it much, I fired out the request. Waking up this morning with a fresh mind, I realized that it wouldn’t be possible, because as you say: which Order’s State? Today it seems like a ridiculous request for obvious reasons. :stuck_out_tongue_winking_eye:

I know there is a solution in here somewhere… I need to map out the flow in a different way. I have been able to get VIP and HH to work together 99% of the time - but in certain scenarios, it fails due to the order of operation on the Ticket/Orders/Entities. I want to make it unbreakable, and I know it can be done; perhaps it needs to be expanded beyond the simplicity that I was hoping for, but I know I can get there.

I wonder… what is State Value used for? Is this like a “note”?

Yes we can think it like a note. For example we store gift reasons there.

It can be discount type… However I won’t recommend using it like that if you are planning to do so. Discount type should be a state as we’ll be able to control from which state to which state it can flow. For example we can have three Discount states for order. VIP, HH and NA (not available).

  • NA can switch to VIP or HH.
  • HH can’t switch to VIP.
  • VIP can’t switch to HH.
  • HH can’t switch to NA
  • VIP can switch to NA.

So our flow constraints can be…

  • NA >> VIP,HH
  • HH >> ?
  • VIP >> NA

All that can be controlled via Current State parameter of Update Order State action. If you fill in Current State value, (eg current state NA, > State VIP) So only orders that currently have NA state will switch to VIP state.

2 Likes

I’ll show one more sample. You can review this sample how to implement even most complex cases by using ticket and order states.

SambaPOSPromo_201411102014SQM.zip (445.2 KB)

This sample also demonstrates how to implement happy hour without configuring triggers and it will be available to all terminals immediately.

You can change this to configure hh enabling rule.

… and this one to configure hh disabling rule.

@QMcKay might not work exactly aligned to your case. I’ve tried to implement constraints I’ve detailed on my previous post.


####Summary

For anyone who missed whole idea I’ll add a short summary here.

We’ve configured three level discounts for customers and each discount level configured individually for each product. For example D1 (think it as member discount) can be %10 for coffee but %5 for wine. Similarly D2 (gold member discount) can be %15 for coffee and %9 for wine. (you can also use fixed amounts instead of rates.)

However we also have Happy Hour implementation (HH Discount) so during happy hour we need to disable member discounts and only apply happy hour discounts. Also after HH period ends additional orders from members should automatically receive member discounts while preserving previous HH discounts. Also Customer switching or removing cases should be handled correctly. HH discounts also should work for tickets without a customer.

wow !! describing it was harder than implementing it :slight_smile:

2 Likes

You make it look so simple @emre. :wink:

I think I have a working solution for my case. But it is very involved…

I added 2 more states for VR (VIP Removed) and HP (Happy Hour Pending). At first it was just for VR, so that HH would not automatically be applied for ND retroactively… then I figured, why not? If the Order fell within the Happy Hour Window, we could check that and honor the HH price. So I put it into a pending state (HP), then run some date/time checks against the Order, and if they pass, HH is applied.

Wow @QMcKay that way you’ve handled much more cases than I’ve thought. Amazing…

While implementing states I was thinking I’m doing something not very useful as too few people will use it. However I’m glad I’ve did it so I’ll be able to learn a lot of things from talented people. I wish I could sit next to you and watch while you’re implementing it… It would teach me a lot of bad-ass ways to improve that.

Anyway how you’re pushing SambaPOS limits sufficiently makes me think about new ways to optimize things. Being able to implement such complex ideas with rules was just one of the essential steps. Now I think we should quickly improve these…

  • Enable disable rules in group by rule tags so we can have multiple implementations of such discounts or similar promotional, loyalty implementations. That allows us to test how slightly different promotion methods performs.

  • Implement something to align custom reports to promotional date ranges to compare differences with other promotional ranges. Learn new things from that experience, choose better performing one, optimize it more and create new ideas to test.

3 Likes