Documentation for the EAN and Barcodes for WooCommerce plugin.

Shortcodes

There are three shortcodes available in the plugin:

  • [alg_wc_ean]
  • [alg_wc_ean_barcode]
  • [alg_wc_ean_barcode_2d]

[alg_wc_ean]

[alg_wc_ean] shortcode outputs product’s EAN.

Attributes
product_id
(Optional) Product ID. If empty, will automatically retrieve the current product ID.
before
(Optional) Content to output before the EAN. E.g. EAN: . Default is empty.
after
(Optional) Content to output after the EAN. Default is empty.

[alg_wc_ean_barcode] and [alg_wc_ean_barcode_2d]

[alg_wc_ean_barcode] and [alg_wc_ean_barcode_2d] shortcodes output product’s 1D and 2D barcodes respectively.

Attributes
product_id
(Optional) Product ID. If empty, will automatically retrieve the current product ID.
before
(Optional) Content to output before the barcode. Default is empty.
after
(Optional) Content to output after the barcode. Default is empty.
children
(Optional) If set to yes, will output variations’ barcodes for a variable product. Default is no.
glue
(Optional) Used to “glue” the variations’ barcodes for a variable product. Used only if the children attribute is set to yes. Default is empty.
w
(Optional) Barcode width. Default is 2.
h
(Optional) Barcode height. Default is 30 for 1D barcodes, and 2 for 2D barcodes.
template
(Optional) Template. Default is %barcode_img%. Available placeholders: %barcode_img%, %product_id%, %product_title%, %value%.
content
(Optional) Sets what have to be encoded in the barcode. Default is ean. Available values are:

ean
Encode product EAN. You can override the product EAN with the ean attribute.
sku
Encode product SKU.
url
Encode product URL.
admin_url
Encode product admin URL. Please note that it will encode parent (i.e. variable) product URL for the variations.
admin_search
Encode product admin search URL.
increase_stock
Encode product increase stock action. You can set quantity with the stock_qty attribute (default is 1). max_stock attribute allows you to set limit for the action, i.e. action can’t increase the stock above the max_stock.
decrease_stock
Encode product decrease stock action. You can set quantity with the stock_qty attribute (default is 1). min_stock attribute allows you to set limit for the action, i.e. action can’t reduce the stock below the min_stock.
add_to_cart
Encode product add to cart action. You can set quantity with the qty attribute (default is 1). You can set user with the user_id attribute (default is 1).
add_to_cart_url
Encode product add to cart URL. Please note that there is no add to cart URL for a variable product, however, you can encode the add to cart URL for the variations.
ean
(Optional) Overrides product’s EAN. Used only if the content attribute is set to ean. Default is empty.
stock_qty
(Optional) Used only if the content attribute is set to decrease_stock or increase_stock. Default is 1.
min_stock
(Optional) Used only if the content attribute is set to decrease_stock. Default is empty.
max_stock
(Optional) Used only if the content attribute is set to increase_stock. Default is empty.
qty
(Optional) Used only if the content attribute is set to add_to_cart. Default is 1.
user_id
(Optional) Used only if the content attribute is set to add_to_cart. Default is 1.
Examples

This will output the 2D barcode for the current product:

[alg_wc_ean_barcode_2d]

This will output the 2D barcode for the selected product:

[alg_wc_ean_barcode_2d product_id="123"]

This will output the 2D barcode for the predefined EAN:

[alg_wc_ean_barcode_2d ean="5901234123457"]

This will encode and output current product URL in 2D barcode:

[alg_wc_ean_barcode_2d content="url"]