How to access Tip ammount in Printer Template

Hi, I added Tips functionality, and also I added a row in the Ticket Printer Template as follows:

Suggested Tip:|[{TICKET TOTAL}*0.1]

This row its because in my country the suggested tip its 10%, so for example, if the order total its $95, the suggested tip its 9.5. Everything prints fine when I Print the Bill before I add the tips, but if I add the Tips in payment screen, and then I Print the Bill, the suggested Tip field its calculated after the Tip:

Order total $95
Tip aded: $9.5
Total: $104.5
Suggested Tip: 10.45---------- (This is the problem)

So I need to make a substraction, something like this:
Suggested Tip:|[=({TICKET TOTAL}-“added tips”)*0.1]

Where “added tips” ammount its the field I dont know how to access.
Also I need some conditional (If, else or something) to print this row only in Tickets “To eat here”, and to not print when Tickets are “To Go”.

any help its appreciated!

How are you adding the tips to the bill?

Can we use an if expression in printer template?

@aaronrrc Instead of using {TICKET TOTAL} use {PLAIN TOTAL}

1 Like

How are you defining these tickets? You may be able to use ternary for this.

1 Like

Awesome, PLAIN TOTAL works, thanks @Jesse !!

Actually Im using default tickets configuration, do I need to add another Ticket Type to differentiate tickets to go? or Can I use some kind of Variable to print or not that row?

No I mean what are you doing to mark ticket as to go or dine in?

At this time nothing, but Im going to do this tutorial to differentiate:

If you use ticket tags then it’s simple ternary operator. Let me get to my computer and I’ll give example in second.

1 Like

If your Ticket Tag for To go was To Go you might try this:

<J00>['{TICKET TAG:StayGO}' == 'To Go' ? 'Suggested Tip:|[=({PLAIN TOTAL}-"added tips")*0.1]' : ' ']

That is checking the ticket Tag StayGO which is what his tutorial has you name it. Its checking if it equals To Go if it does then it displays whats after the ? if it doesnt match it displays whats after the : so by using ' ' it means display nothing.

if statements are used in Jscript with the scripting but they are not part of the printer template expressions. What I demonstrated is a ternary operator which acts similar to an if statement.

No but as I showed above you can use Ternary Operator.

Should be
['{TICKET TAG:StayGO}' == 'Dine In' ? 'Suggested Tip:|[=({PLAIN TOTAL}-"added tips")*0.1]' : ' ']
He want to show Tip when Dine In.

1 Like

Yes it should but concept is same. He can set it up however he wants.

@Jesse it works great!, anyway I realized that in my restaurant, when I select a customer it means its an order To Go, so I need to use something like this:

<J00> ['{ENTITY NAME:Customer}' == '' ? 'Dine In' : 'To Go'] 

But this ternary doesnt works, it prints out:

’ A a r o n R o d r i g u e z ’ = = ’ ’ ? ’ Dine In’ : ’ To Go ’

any ideas?, maybe I have to make something like this thread:

Could you just clarify the use of that?
X==Y ? [if true] : [if false]
Excuse the lack of formatting etc am on phone and hard to see you post while typing…

Sure, Im trying to know if Customer Entity its empty, If Its empty then I will print ‘Dine In’, but if its not empty then I will print ‘To Go’

I understand what your looking to do, just wanting to check I understood the ? Function, ie true:false order.

The ? symbol its asking if the sentence its true, in this case, if entity customer its ‘’ (empty), then print ‘Dine In’, at least thats my understanding, correct me if Im wrong please

@aaronrrc try this:

<J00>[='{ENTITY NAME:Customer}' == '' ? 'Dine In' : 'To Go']

1 Like

Thats it @kendash, lack of = symbol, thanks a lot for your help!!!

1 Like

@Jesse A little issue again with this line:

[=’{ENTITY NAME:Customer}’ == ‘’ ? ‘Suggested Tip:|[={PLAIN TOTAL}*0.1]’ : ‘’]

It Prints: ’ : ‘’]

Thats because of the [ ] internal signs, are there substitution characters for that signs or something?