Printer Template fixed string


I am trying to figure out how to fix the order strings to a fixed length of string to display. I am not currently in front of the test machine. Is there any function for that?

I am sorry but what is an order string?

the order menu item description

What do you mean by a fixed length of string to display? So your talking about the menu item name? Do you have a long description that you want to shorten?

Correct. I just want to display only a fixed string length of the menu item name

Go to your menu and change the Header to whatever you want. Menu > Edit Product Properties. Set Header for each product to what you want.

No, what I want is to not to change anything on the menu item. Just when we print the ticket or receipt

That would have been good to know :stuck_out_tongue: Ok before I give another answer can you be more descriptive? maybe show some examples? And try to use the actual names of the features. Order Strings really threw me off as nothing in SambaPOS is called Order Strings.

Menu item: some-dishes-with-long-name-to-be-printed-on-ticket

Then I just want to show this on ticket/receipt: some-dishes-with-long

I was wondering if SambaPOS has some helper function similar to:

[=substring([Order Item],1,10)]

for example

Ok so some of your dishes have really long names and you just want part of that name showed on ticket? Hmm there is helper functions available but I am not sure if it works on Orders. I have not seen anything in the forum similar to this request.

Have you considered just shortening the name? I mean it could still show the long name on Menu using Header like I described but product would be shorter for printing purpose.

Yes, that would be one solution but I just wonder if we could do this with some helper functions

Try this:


I guess I am going after this issue of alignment:

I want to print:


So I need a fixed column width in the name.

How can this be done?

This will justify the Price and Total Amount to the Right, and the Quantity and Name to the Left.

If the Name is too long to fit, it will simply be truncated.


If for some reason you feel that you must set a fixed length, you can use this:

<J00>{QUANTITY} [='{NAME}'.substr(0,5)]|{PRICE} {TOTAL AMOUNT}

Specifically, this part sets the number of characters:



I moved 3 posts to a new topic: Using JScript functions in Printer Templates

Thanks @QMcKay. It was exactly what I am looking for

We start with this for an Order Line on a printed Ticket:



1 Milk.Small                   40.00 40.00
10 Tea                        40.00 400.00
100 Water Small             30.00 3,000.00

Padding of Quantity:

<J00>[=('{QUANTITY}'+"    ").substr(0,4)] {NAME}|{PRICE} {TOTAL AMOUNT}

Specifically, we are right-padding Quantity to 4 characters:

[=('{QUANTITY}'+"    ").substr(0,4)]


1    Milk.Small                40.00 40.00
10   Tea                      40.00 400.00
100  Water Small            30.00 3,000.00

While we’re at it, how about we fix Price and Total Amount alignment …

<J00>[=('{QUANTITY}'+'    ').substr(0,4)] {NAME}|{PRICE} [=('       ').substr(0,(7-TN((F('{TOTAL AMOUNT}','0.00')).length)))+F('{TOTAL AMOUNT}','0.00')]

Specifically, we are left-padding Total Amount to 7 characters:

[=('       ').substr(0,(7-TN((F('{TOTAL AMOUNT}','0.00')).length)))+F('{TOTAL AMOUNT}','0.00')]


1    Milk.Small              40.00   40.00
10   Tea                     40.00  400.00
100  Water Small             30.00 3000.00