Scanning & Fulfillment
Custom barcode expression
By default the scannable barcode for each order line item is the barcode set on the product variant in your product catalog. If, however, the barcode you wish to scan during fulfillment is not the same as the product variant barcode, (or SKU), you can substitute the desired barcode using a custom barcode expression.
A barcode expression is a Liquid code snippet that evaluates to a string. It is not necessary to fully understand Liquid to use this feature, but you can use Liquid to create more complex expressions if needed. You can always contact us for help with creating a custom barcode expression.
You may need to use this feature if:
- You are generating a barcode value for ordered products during checkout (e.g. stored in a line item property).
- You want to use barcode data stored in a metafield on the product variant.
- You are producing and selling customised products that have a barcode assigned at some point during production.
- You have products labelled with a barcode that is different from the SKU or Barcode but is stored elsewhere in your product database (e.g. in a metafield) or can be derived from other product or line item data.
Liquid variables available to you in the custom barcode expression:
line_item.properties
- any custom line item properties stored during checkoutline_item.variant.barcode
- the variant barcodeline_item.variant.sku
- the variant SKUline_item.sku
- the variant SKU at order timeorder.name
- the order object
Please get in touch if you need to access other order or line item attributes in your custom barcode expression. We are happy to add more variables as needed.
Example 1: Using a line item property
Lets assume you sell highly customised products, and you generate a barcode for each product during checkout. If you have an automatically generate line item property called BARCODE
that stores the barcode you want to scan during fulfillment, you can use the following expression:
{{ line_item.properties.BARCODE }}
If there is no property present, then the barcode will be empty and Scan to Ship will show a “barcode missing” message during scanning. If you want to fall back on the product variant barcode if the line item property is not set, you can use the following expression:
{% if line_item.properties.BARCODE %}
{{ line_item.properties.BARCODE }}
{% else %}
{{ line_item.variant.barcode }}
{% endif %}
Example 2: Using a barcode value derived from other data
Lets assume you have a workflow with a custom barcode label that is derived from the product variant SKU and the order number. You can use the following expression:
{{ line_item.variant.sku | append: "-" | append: order.name }}
Example 3: Using a product variant metafield
If you want to store the barcode in a metafield on the product variant, you can use the following expression:
{{ line_item.variant.metafields.scanpacker.my_barcode }}