Happy hour ticket template

OK, i ll show u everything,

First, i defined a new order state called hh:

Then, I created a new action to change the price to a previously defined price tag hh:

Then, i created a new action to update the order state:

Then, i created a new rule to let everything work together:

and my ticket template is:

[LAYOUT]
-- General layout
<BMP>C:\Users\bandy\Desktop\logo.bmp
<T>Ticket
<L00>Date:{TICKET DATE}
<L00>Time:{TIME}
{ENTITIES}
<L00>Ticket No:{TICKET NO}
<F>-
{ORDERS}

<F>=
<EB>
{DISCOUNTS}
[<J10>Total Gift:|{ORDER STATE TOTAL:Gift}]
<J10>Total:|[=F(TN('{TICKET TOTAL}')*1,'#')] LBP
<J10>     :|[=F(TN('{TICKET TOTAL}')*0.00066667,'0.00  ')] $
{PAYMENTS}
<DB>
<F>=
<C10>T H A N K   Y O U

[DISCOUNTS]
<J00>{CALCULATION NAME} %{CALCULATION AMOUNT}|{CALCULATION TOTAL}

[PAYMENTS]
<J00>{PAYMENT NAME}|{PAYMENT AMOUNT}

[ORDERS]
-- Default format for orders
<J00>-  {QUANTITY} {NAME}  |[=F(TN('{PRICE}')*{QUANTITY},'#')] LBP {ORDER STATE:hh}
{ORDER TAGS}

[ORDERS:Gift]
-- Format for gifted orders
<J00>- {QUANTITY} {NAME}|**GIFT**
{ORDER TAGS}

[ORDERS:Void]
-- Nothing will print for void lines

-- Format for order tags
<J00> * {ORDER TAG NAME} | {ORDER TAG PRICE}

[ENTITIES:Table]
-- Table entity format
<L00>Table: {ENTITY NAME}

[ENTITIES:Customer]
-- Customer entity format
<J00>Customer: {ENTITY NAME} | {ENTITY DATA:Phone}

The result is that the price is changing perfectly according to the rule but the hh doesn’t appear on the bill so i guess the problem is with the update order state action

Hh wouldn’t appear. It would say Activated in the ticket.

Does it not print Activated?

Like I mentioned you do not have to define the state under Settings > States

Can you show a printout using that setup?
Also please highlight your template and press the </> button please.

Ok then where shld i define the hh state or u mean i don’t need to define it at all?
this is the template

    [LAYOUT]
-- General layout
<BMP>C:\Users\bandy\Desktop\logo.bmp
<T>Ticket
<L00>Date:{TICKET DATE}
<L00>Time:{TIME}
{ENTITIES}
<L00>Ticket No:{TICKET NO}
<F>-
{ORDERS}

<F>=
<EB>
{DISCOUNTS}
[<J10>Total Gift:|{ORDER STATE TOTAL:Gift}]
<J10>Total:|[=F(TN('{TICKET TOTAL}')*1,'#')] LBP
<J10>     :|[=F(TN('{TICKET TOTAL}')*0.00066667,'0.00  ')] $
{PAYMENTS}
<DB>
<F>=
<C10>T H A N K   Y O U

[DISCOUNTS]
<J00>{CALCULATION NAME} %{CALCULATION AMOUNT}|{CALCULATION TOTAL}

[PAYMENTS]
<J00>{PAYMENT NAME}|{PAYMENT AMOUNT}

[ORDERS]
-- Default format for orders
<J00>-  {QUANTITY} {NAME}  |[=F(TN('{PRICE}')*{QUANTITY},'#')] LBP {ORDER STATE:hh}
{ORDER TAGS}

[ORDERS:Gift]
-- Format for gifted orders
<J00>- {QUANTITY} {NAME}|**GIFT**
{ORDER TAGS}

[ORDERS:Void]
-- Nothing will print for void lines

-- Format for order tags
<J00> * {ORDER TAG NAME} | {ORDER TAG PRICE}

[ENTITIES:Table]
-- Table entity format
<L00>Table: {ENTITY NAME}

[ENTITIES:Customer]
-- Customer entity format
<J00>Customer: {ENTITY NAME} | {ENTITY DATA:Phone}

and this is an order

:

and this is its bill:

Your Rule called Happy Hour Activated should use Matches All, not just Matches.

As is, your Ticket is not showing that the Order State has been updated. This may be because the Rule Constraints with just Matches is somewhat unpredictable.

Also, delete the hh State that you have defined. It is not necessary. You only require the Action that updates the Order State. This may be your problem, since you have defined a hh State Group, but have only hh as a State, and Activated is not a valid State because of your State definition.

@QMcKay your reply touches a point i’ve not quite worked out, what is Matches ment to do?
There is Matches Any and Matches All where does just Matches come?

First, these are fairly intuitive:

  • Matches All : all constraints must evaluate to True before the Rule will fire. This is like AND.
  • Matches Any : any constraint evaluated as True will allow the Rule to fire. This is like OR.
  • Not Matches All : all constraints must evaluate to False before the Rule will fire. This is like NOT AND.
  • Not Matches Any : any constraint evaluated as False will allow the Rule to fire. This is like NOT OR.

Matches is a bit special. If any parameters on the left side of the list have the same name, they will be considered as an OR condition, while the other parameters are considered as AND.

{DATE:ddd} Matches Mon|Tue
{TIME} After 1430
{TIME} Before 1445
Menu Item Group Code Equals Classics

With Matches, the above means:

     (Date is Monday or Tuesday)
 AND (Time is After 1430 OR Before 1445)
 AND (Group Code is Classics)

The issue is the {TIME} parameter … you don’t want it to be an OR condition; instead you want it to be an AND condition in this case.

Using Matches All, the logic is different:

    (Date is Monday or Tuesday)
AND (Time is After 1430)
AND (Time is Before 1445)
AND (Group Code is Classics)

P.S. There are many legitimate cases for the use of Matches, but in this scenario you do not want to use it; you want to use Matches All.

2 Likes

Sorry you are right it should be matches all. I built I quick and I did change it to matches all but I had already took the sshot and forgot to take another.

Also he is right you should delete that state definition its setup wrong but you don’t need it anyway.

Like I said previously state definitions are specifically to show color changes.

I used activated as a sample if you want it to show as HH on ticket replace activated with HH.

Thanks @QMcKay that is a great explanation, much appreciated.
Just to elaborate in my own mind and for anyone else who might read am I right to then say that the reason Matches doesn’t work in the topic situation is that;

{DATE:ddd} Matches Mon|Tue
{TIME} After 1430
{TIME} Before 1445
Menu Item Group Code Equals Classics

Which as you say can be defined as;

(Date is Monday or Tuesday)
 AND (Time is After 1430 OR Before 1445)
 AND (Group Code is Classics)

Would be handled by samba as ‘two constraint’ conditions;

(Time is After 1430) AND (Group Code is Classics)
OR
(Time is Before 1445) AND (Group Code is Classics)

Meaning that the time based constraint is always valid as its always After 1430 or Before 1445 at any time of a particular day.

That wouldn’t explain the state not working. I think that’s simply because he defined the state wrong.

But yes it would always activate which is not what we want. So matches all would fix that.

Exactly correct. The Time constraints are useless in this case with Matches.

1 Like

I agree. I believe the definition of the State is what is making this not work. I think removing the State will fix the issue.

@QMcKay @Jesse No the problem is that the {TIME} constraints are not working somehow , when i remove it the hh appears on the bill, so i dont know what to do , in the happy hour triggers method the time triggers works perfectly and i can change the price List to hh but the rule with the trigger executed event doesn’t seem to have an action based on “update order state”, the only event that accept the update order state action is the “Order added to Ticket” event

So I can have to working rules, one using the “trigger executed” event to set the happy hour time and change the price List and the other using the “order added to ticket” event to update the order state so it can appear on the bill

So is there a way to relate these two rules so they can work at the same time? thank u

Start from the beginning… your using triggers plus this method?

The setup posted by me does not use Triggers, and it does not use Price Definitions either. It uses Order States and Order Tags to apply discounts.

From the sound of it he has ended up with a miss match of the two methods…

Well yeah but the {TIME} before and {TIME} after constraint are not working in my setup, thats why i switched to the trigger method and it worked but i just need to show the hh letters on happy hour orders on the bill so i used an action to update the order state to hh but it cant work with the same rule of the triggers, so im just asking if i can let them work together, the rule using trigger executed event and the other rule using the order added to ticket event

There is always a way LOL but triggers are timed changes, not a time range, you would have to do something like setup a happy hour program setting change on the triggered rules and then use that program setting as a constraint on your HH tags/state (order added rules) bit of a round about way when the time constraints would be allot simpler.
If the time constraints didn’t work it would have been an error somewhere in the settings as is a tried and tested method.
Did you change to MATCHES ALL like @QMcKay said?

@Comfnmb can you show your rule where your using {TIME} it does work I use it every day. You must have configured something wrong.

@Jesse, @JTRTech those are my update order state action and rule:

Where it says Execute rule if: Change it from Matches to Matches All see if that fixes it.

Also it should be 12:24 and 12:45 you must insert the : I know that was my fault in the tutorial I gave you I will fix that.

EDIT: Fixed my original screenshot sample.

4 Likes