How to remove decimal places in a print template function

Say I have this function [=F(6-('{ENTITY DATA:Points}'))]

It resolves to be something like 2.00

How could I go and get it to return 2

Another related question

How could I go ahead and make it return You have a free drink if that orgianl function returns <0 i.e. 0 or -1 or less

Use ternary operator in an expression, something like:

[=(6-TN('{ENTITY DATA:Points}')) <= 0 ? 'You have a free drink' : 'somethingElse' ]
1 Like

Well no offence but that looks really complicated… I’ve gone with using my webserver to deliver me a nicer looking html custom screen. It works well and can show my recent orders as well.

Its not that complicated :stuck_out_tongue:
Its just an if type statement;

[= (X = Y) ? 'True Value' : 'False Value' ]
....^^^^^ That part being the if expression

1 Like

I don’t understand how a single expression [quote=“QMcKay, post:2, topic:12191”]
[=(6-TN(’{ENTITY DATA:Points}’)) <= 0 ? ‘You have a free drink’ : ‘somethingElse’ ]

Is more complicated than:

But anyway your solution probably is better.


No! Its not that the expression is difficult, It’s I want to generate a customer display screen which is entirely tailored based on what type of customer it is. It’s more I feel a lot more confident in PHP than those kind of expressions. For example, after I provide my webserver the entity’s name it comes back with an already formatted screen asking if they would like to reorder there last order before showing them recent orders as well as different promitons based on different entity custom fields, and if it is a certain customer type then show there account, or if it is a different customer then not display anything.

I could do everything in Samba with about 10 different print templates for the same things but I feel it’s easy just having a php file to format everything in html already done. Ill just show you what my current PHP setup looks like to see the complicated nature of it.

Hey Q, or anyone else how can I take this expression[quote=“QMcKay, post:2, topic:12191”]
[=(6-TN(’{ENTITY DATA:Points}’)) <= 0 ? ‘You have a free drink’ : ‘somethingElse’ ]

and make it be so that if Points not equals null, do this?

TN function should handle null values.

That doesnt seem to work
[=(TN('{ENTITY DATA:Points}')) = '' ?
I do have 2 statment after the ? just their really long and are not relevant to the question

TN (to number) converts it to a number to be able to eval <= operator so it never becomes =''.

1 Like

Ok, so say I wanted to say if it equals null, because thats how I track if the customer has bought from us before and if so then they will be in my online db but if they havent I need to use sambaPOS to generate the Html.

Like in a rule I do

How would I do that?

Like why does this not work?
[=('{ENTITY DATA:Points}') = '' ?

Because = is an assignment operator. You need to use == to check a condition.

[=('{ENTITY DATA:Points}') == '' ?
1 Like

Small Explanation:

[=<expression>] syntax is used to execute JS code. [= and ] Brackets used to define where it starts and ends.

So the complete sample should be:

[='{ENTITY DATA:Points}' == '' ? 'Is Empty' : 'Is Not Empty']
1 Like