cancel
Showing results for 
Search instead for 
Did you mean: 

Barcode type Shipstation uses? I want to export orders in Excel and create Barcodes for ORDER ID

SilverLakeTees
Occasional Contributor

anyone knows what type of barcode SS uses? it reads something like this "ì^#^1418A660^=î" no idea what is it, order id of that order is "111­1711204­8385002" I wanted to get same codes and be able to pull up order, I can use ORDER ID, but somethings its too long or too short, so its a problem on small barcode label. 

1 REPLY 1

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)
}