Parsing barcode/QR code made up of multiple item possible?

Hi there, I’m trying to input multiple items from scanning a single barcode/QR code, and was wondering if this possible with SambaPOS?

For example: 3 products from the menu,

  • Coke, barcode: 9001
  • Sprite, barcode: 9002
  • Fanta, barcode: 9003

Combine these 3 into a long barcode such as

88 03 9001 9002 9003 77

88 and 77 are marker for his special barcode, 03 meaning there are 3 product barcodes in this series, and SambaPOS would know to read 9001, 9002, & 9003, and add these items to ticket.

Is this possible with automation?

Thanks in advance

Hey @biggarys

I cannot give you the exact steps for automation but using JScript you can parse the 1 value into the bits required i.e. 9001, 9002 etc and then use automation to add items to a Ticket. JScript has some fairly good text handling features so Google will bring up actual source to test.

Place your source in a SambaPOS Script and use {CALL:x} to return the values into Automation. In some cases you can use JSCRIPT directly in a Constrain or Parameter with needing a call. I find sometimes a CALL is better as my constraints can blow out in length.

1 Like

@biggarys just wondering what is the scenario you are using this for?

In a quick service restaurant scenario with complex menu. I can potentially let customers create their own order on their phone, and the app will turn their order into a barcode which they come to the front counter and place their order with the barcode. If that make sense at all.

2 Likes

Good idea! I’m sure we can automate something

This shouldn’t be too hard with jscript few slice functions in a for loop :wink:

So long as you have a consistent format at least up to the qty number at the beginning and ideally consistent lengths of bar-codes would make life easier.
Or posibly loose the qty prefix and prefix each barcode string with a unique value which can be indexed and used to break apart
Slice out the qty and then loop a few more slices to pull the individual numbers.

Only bit im not sure about would be the adding of the products.
Should be doable with a loop value action.
The script returning a comma separated list of barcodes into a loop value action triggering add order actions.
Although never used the loop value action myself.

1 Like

Good to know it’s possible with SambaPOS, but it’s probably going to be a challenge for me given my very limited experience with SambaPOS.

I was thinking perhaps there’s quick and dirty way of of doing it , ie. append carriage return/line feed after each item code. ie 900190029002

Anyone done anything similar with barcode?

Have not seen anything myself on the forum.
Can you put a comma in a barcode? could try that…

The script wouldnt be that hard… can soon whipe something up if you let me know the layout/format you intend to use and a couple of sample strings…

1 Like

see what your thinking but not sure carrage return is a barcodeable function.
A scanner would add a return as a suffix usually as an ‘enter’ after the code entered.

comma would be better as pretty sure the loop values action needs comma seperated list

1 Like

Hmmmm… might be possible…

Basically you will need to include a ~013 in the Data To Encode text box where ever you need the carriage return to be. For example, for the data 1234567890, you would use 12345~01367890. When scanned the carriage return will be between the 5 and 6. Also the Apply Tilde in Code 128 option needs to be set to Yes or True.

If it were to work I think you would need to turn the scan speed down to allow time to process.
Saying that were you even using a barcode scanner??

Thanks JTRTech, that’d be awesome if you could start me on something.

I haven’t decided on a format yet, probably something similar to this

8888 9001 9002 9003 7777

basic concept is that

8888 is the marker for the beginning of special barcode
7777 is the marker for the end of the special barcode
product codes are in 9xxx format

when SambaPOS process a barcode input, it checks
IF the first 4 digit of the barcode is 8888,
THEN it knows it’s the beginning of the special barcode, and will read 4 digits at a time, enter it as a product, until it reaches 7777 (end of the special barcode)
ELSE treat the input as normal barcode, and process normally

Not sure youll need the 8888 and the 7777…
All you want is a way for the numberpad entered rule to know its a multi product code so say the 8888 would suffice.

Yes, have got a barcode scanner with 2D capability, so QR code is an option, which should allow me to encode a long list of products in the code.

Specific reason why you dropped the product qty field at the beginning?

Either way…
Here is a quick rough and ready script which should return a comma separated list of barcodes for use in a loop value action.
This is based on the given format and all segments being 4 digets separated by spaces.

function multiBarcodeSplitter(inputBarcode) {
	var multiBarcode			= inputBarcode;
	var listBarcode				= multiBarcode.split(" ");
	var listLength				= listBarcode.length-2;
	var productString			= '';
	for(var i = 1; i<listLength+1;i++) {
		productString			+= listBarcode[i]+',';	
		}
	var slicedListString		= productString.slice(0,listLength*5-1);
return slicedListString
}

8888 9001 9002 9003 9005 9006 9007 7777#
would return
9001,9002,9003,9005,9006,9007

1 Like

Thought it might make the coding system more robust, in case people try to temper with the barcode.

eg. qty field of 5 and only 2 product codes follows…etc (similar to the concept of buffer overflow)

Or add in some test if expressions;

function multiBarcodeSplitter(inputBarcode) {
	var multiBarcode			= inputBarcode;
	var prefix					= multiBarcode.slice(0,4);
	if (prefix==8888) {
		var listBarcode				= multiBarcode.split(" ");
		var listLength				= listBarcode.length-2;
		var productString			= '';
		for(var i = 1; i<listLength+1;i++) {
			productString			+= listBarcode[i]+',';	
			}
		var result		= productString.slice(0,listLength*5-1);
		} else {
		var result = 'Not a valid multi-product barcode'
		}
return result
}

If you put the qty segment back in you could also varify that the qty matches the barcode qtys

This one checks several factors;

  1. Does the first segment = 8888

     var prefix					= multiBarcode.slice(0,4);
     if (prefix==8888) {
    
  2. Are all segments 4 didgets

     	for(var c = 0; c<codeLength;c++){
     		var loopSegment			= listBarcode[c];
     		var loopSegmentLength	= loopSegment.length;
     		if (loopSegmentLength==4) {
     			//If four digets do nothing
     			} else {
     			var allFourDiget	= 'No';
     			}
     		}
     	if (allFourDiget=='Yes') {
    
  3. Does the second segment (barcode listing of product qty) match the counted number of codes

     		var listLength				= listBarcode.length-3;
     		var barcodeQty				= Number(listBarcode[1]);
     		if (listLength==barcodeQty) {
    

Full code;

function multiBarcodeSplitter(inputBarcode) {
	var multiBarcode			= inputBarcode;
	var prefix					= multiBarcode.slice(0,4);
	if (prefix==8888) {
		var listBarcode				= multiBarcode.split(" ");
		var codeLength				= listBarcode.length;
		var allFourDiget			= 'Yes';
		for(var c = 0; c<codeLength;c++){
			var loopSegment			= listBarcode[c];
			var loopSegmentLength	= loopSegment.length;
			if (loopSegmentLength==4) {
				//If four digets do nothing
				} else {
				var allFourDiget	= 'No';
				}
			}
		if (allFourDiget=='Yes') {
			var listLength				= listBarcode.length-3;
			var barcodeQty				= Number(listBarcode[1]);
			if (listLength==barcodeQty) {
				var productString			= '';
				for(var i = 2; i<listLength+2;i++) {
					productString			+= listBarcode[i]+',';	
					}
				var result		= productString.slice(0,listLength*5-1);
				} else {
				var result = 'Barcode QTY doesnt match ready qty';
				}
			} else {
			var result = 'A segment of the barcode has either been misread or is invalid';
			}
		} else {
		var result = 'Not a valid multi-product barcode';
		}
return result
}

This is on basis of following format;
8888 0005 9002 9002 9003 9004 9005 7777

Segments;

  1. 8888 prefix
  2. 0006 four digit barcode product qty
    3-7. Product codes
  3. 7777 suffix

This checks both the 8888 prefix and 7777 suffix;

function multiBarcodeSplitter(inputBarcode) {
	var multiBarcode			= inputBarcode;
	var prefix					= multiBarcode.slice(0,4);
	var suffix					= multiBarcode.slice(-4);
	if (prefix==8888 && suffix==7777) {
		var listBarcode				= multiBarcode.split(" ");
		var codeLength				= listBarcode.length;
		var allFourDiget			= 'Yes';
		for(var c = 0; c<codeLength;c++){
			var loopSegment			= listBarcode[c];
			var loopSegmentLength	= loopSegment.length;
			if (loopSegmentLength==4) {
				//If four digets do nothing
				} else {
				var allFourDiget	= 'No';
				}
			}
		if (allFourDiget=='Yes') {
			var listLength				= listBarcode.length-3;
			var barcodeQty				= Number(listBarcode[1]);
			if (listLength==barcodeQty) {
				var productString			= '';
				for(var i = 2; i<listLength+2;i++) {
					productString			+= listBarcode[i]+',';	
					}
				var result		= productString.slice(0,-1);
				} else {
				var result = 'Barcode QTY doesnt match ready qty';
				}
			} else {
			var result = 'A segment of the barcode has either been misread or is invalid';
			}
		} else {
		var result = 'Not a valid multi-product barcode';
		}
return result
}
1 Like

Wow, thanks for that JTRTech, will see if I can incorporate it into my system somehow :slight_smile:

Put in a new script, name whatever aned put handeler of say ‘BarcodeTools’.

Then in your automation flow where you need to use put {CALL:BarcodeTools.multiBarcodeSplitter('[:NUMBERPAD]')}

That call might not be 100% correct as not on machine to check the numberpad tag but its something like that, if you click a constraint dropdown on a number pad entered event it should show you, it might be [:NumberPad], cant remember off the top of my head.