YITH WooCommerce Barcodes lets you render a barcode everywhere you need, you have to simply use the following shortcode:
[yith_render_barcode]
With this shortcode you can render a barcode or QR code for a specific product or you can render a barcode(or QR code) based on a specific value; you can use it everywhere you need, on the single product page, on cart page, on checkout page and so on.
The available parameter are the following:
‘id’
(int) The product id from which the barcode should be shown
‘hide_if_empty’
(int) set it to 1 if you do not want to show any text in case the barcode does not exists for a specific product id.
If is set to 0, a message will be shown stating that there aren’t any barcode for the specified product.
Default: 1
‘value’
(string) enter a specific value for which a barcode representation will be shown.
‘protocol’
(string) enter a barcode protocol to use when a barcode representation should be shown for a specific value.
At the moment you can choose one of the following protocols:
‘EAN13’, ‘EAN8’, ‘STD25’, ‘INT25’, ‘CODE39’, ‘code93’, ‘code128’, ‘Codabar’, ‘QRcode’.
Default: ‘EAN8’
Examples
Show the barcode for a specific product
You can show a barcode representation for a product using the ‘id’ attribute. The following example will show the barcode for the product with id 99.
[yith_render_barcode id="99"]
The result will be:
Show the barcode for a specific value in EAN8 protocol
You can show a barcode representation given the value and the barcode protocol you choose to use.
The following example will show the barcode for the value ‘9934’ using the protocol ‘EAN8’.
[yith_render_barcode value="9934" protocol="EAN8"]
The result will be:
Show the barcode for a specific value in EAN13 protocol
You can show a barcode representation given the value and the barcode protocol you choose to use.
The following example will show the barcode for the value ‘145634’ using the protocol ‘EAN13’.
[yith_render_barcode value="145634" protocol="EAN13"]
The result will be:
Show a message is a product does not have any barcode generated
If you want to show a barcode value of a product that do not exists or for which the barcode value is not generated yet, you can use the following code.
[yith_render_barcode id=1209934 hide_if_empty="0"]
The result will be: