cancel
Showing results for 
Search instead for 
Did you mean: 
eComm_Canada
New Contributor
Status: New

It would be great if we could have the option for any of the barcodes generated in ShipStation to be set to the order number values and not the Quick Ship special character values. The order summary report that has barcodes for each order cannot be scanned by our WMS as the barcodes are a special ShipStation code and do not reflect the actual order numbers barcode. Having the ability to scan order numbers via barcodes would be great for overlapping systems. Thanks 

1 Comment
VikingGawd
New Contributor

The barcode is the order id encoded to hexadecimal with ^#^ in the beginning and ^ at the end.

so an id of 11234567 in the api would be a value of AB6D07. So the barcode would be ^#^AB6D07^.  

Was looking for years and finally noticed the correlation one day.

 

PHP:

$orderId = 11234567;
$barcode = '^#^' . strtoupper(dechex($orderId)) . '^';

And reverse barcode to order ID:

$fromBarcode = '^#^AB6D07^';
if (preg_match('/\^#\^[a-fA-F0-9]*\^/', $fromBarcode) === 1) {
$fromOrderId = hexdec(substr($fromBarcode, 3, -1));
}

Javascript:

const orderId = 11234567

const barcode = `^#^${orderId.toString(16).toUpperCase()}^`;
const barcodeLegacy = '^#^' & orderId.toString(16).toUpperCase() & '^';
 
And Reverse
const fromBarcode = '^#^AB6D07^'
let fromOrderId = null
if (/\^#\^[a-fA-F0-9]*\^/.test(fromBarcode)) {
fromOrderId = parseInt(fromBarcode.slice(3,-1), 16)
}