WooCommerce - Order Barcodes

Modified on Wed, 17 Feb 2021 at 02:34 PM

WooCommerce Order Barcodes

WooCommerce Order Barcodes generates unique barcodes for every order placed on your site. These barcodes can be used on e-tickets, e-reservations, packing slips or anything else that would benefit from having a scannable barcode attached to it.

Note: Order Barcodes creates a single barcode per order. It does not create a barcode for each item on the order.

Barcodes are generated for every order as soon as they are placed.

They are also generated for orders that are created manually via the WordPress dashboard. Once an order has been placed, the barcode is included in all order emails as well as the order details page in the customer’s WooCommerce account area. This allows the customer to easily print out the barcode if necessary.

Important: If you are using WooCommerce Order Barcodes in combination with WooCommerce Box Office you will also get an individual barcode for each ticket. This barcode will not be mailed out. Customers need to print it from the order screen (link in the confirmation email).

The unique barcode as it appears on the order details page
A unique barcode, as it appears on the order details page

Installation

  1. Download the .zip file from your WooCommerce account.
  2. Go toWordPress Admin > Plugins > Add New and Upload Plugin with the file you downloaded with Choose File.
  3. Install Now and Activate the extension.

More information at: Install and Activate Plugins/Extensions.

Setup and Configuration

  1. Go to: WooCommerce > SettingsGeneral.
  2. Scroll down to Order Barcodes.
    • Select Barcode Type (see below for examples)
    • Select Barcode Colors
  3. Save changes.

Changing settings will only affect future barcodes. Barcodes that have already been created are unaffected.

Barcode Types

There are five barcode types available when using the WooCommerce Order Barcodes extension. Here are examples of each:

Examples of the five available barcode types
Examples of the five available barcode types

Code 39, 93 and 128 barcodes will work with standard USB barcode scanners, while the Data Matrix and QR Code types will work with digital scanners and mobile devices. The barcode type you should use will depend on the best solution for your use case.

Usage

Generating barcodes

Barcodes are generated automatically when the extension is active, so you don’t need to do any extra setup to get that side of things working correctly. You can view existing barcodes on the order edit screen in the WordPress dashboard:

A barcode displayed on the order edit screen
A barcode displayed on the order edit screen

Scanning barcodes

In order to scan your barcodes, you can use the [scan_barcode] shortcode. This will generate a form that looks like this:

Barcode scan form

This form will only be usable by users with the manage_woocommerce capability. It allows you to scan or enter a barcode and perform one of four actions on the order to which it is linked:

  • Look up – This will simply look up the order details and display them on screen.
  • Complete order – This will mark the order as complete and then display the order details on screen.
  • Check in – This will mark the order as ‘checked in’ and then display the order details on screen.
  • Check out – This will mark the order as ‘checked out’ and then display the order details on screen.

You can pre-select one of these options using the action parameter of the shortcode by setting it to one of the following: lookupcompletecheckin or checkout. The shortcode with a pre-set action will look like this: [scan_barcode action="checkin"]. All actions are performed via ajax so the page does not reload after running them – this means you can scan in barcodes rapidly without long wait times between each scan. The order details are displayed using the view-order.php template, so if you have customized that template on your site then they will follow those same customizations.

Using a smartphone or tablet

The most common way to scan barcodes for events is by using a smartphone or tablet. This can be easily achieved by using the scanning form along with a free app on your phone or tablet. All you need to do is load up the page with the scanning form in the browser of your smartphone or tablet and then open up one of the many apps available for this purpose and you can scan your barcodes quickly and easily. We do not make any of these apps, but here are two that are very effective:

  • Barcode Scan to Web for iOS
    • Tips for use:
      1. Access the app settings and enter the URL for your check-in page as the homepage URL
      2. Use the “back arrow” at the top to return to the home screen, and then click the home icon at the bottom to refresh. You should then see the check-in page, but not the form itself. You will need to log-in to see the check-in form.
      3. Go to the address bar at the top and edit the URL to go to /wp-admin
      4. This will take you to the standard WordPress login screen, where you’ll need to log in.
      5. Once logged in, hit the home button again at the bottom to re-load the check-in page and you’ll be ready to scan barcodes!
  • Barcodescanner Keyboard for Android

We obviously cannot guarantee these apps, but they are the ones that we have found effective in our testing. You can do a simple search of the iTunes Store as well as the Google Play Store to find other similar apps as well. Specific usage instructions will be available in the apps themselves.

Using a USB scanner

If you are using a USB scanner to scan in your barcodes, then the scanner will be automatically detected and the action will be performed without you having to click the ‘Go’ button. This will save a lot of time when, for example, scanning e-tickets at the door to a concert.

Manually typing in a barcode

When manually typing in a barcode you must type in the full string of text that appears below the barcode and then hit enter or click the ‘Go’ button.

Generating barcodes for existing orders

Existing orders will not automatically have barcodes added to them. In order to generate barcodes for these orders, you simply need to visit the order page in the WordPress dashboard and a unique barcode will be generated and added to the order as you load the page.

Troubleshooting

Barcodes not displaying in Gmail (version 1.3.18 and below)

If you happen to hear of, or see any, issues with the barcode displaying in Gmail, it may be a setting to change and things will work as expected. Head into your Gmail settings and the General tab. There will be a section for images. Change it to “Always display external images” and the barcode should now work.

Barcodes still not displaying in Gmail – hosting with WPEngine (version 1.3.18 and below)

Images displayed directly in Gmail are loaded through a proxy in order to protect user security. This means that images are downloaded by a Google Proxy Server before being shown in your email client.

If you’re still not seeing images in Gmail after applying the above Gmail settings and your site is hosted with WP Engine, the GET requests from Google Proxy Servers might be getting redirected, preventing the images from being downloaded. Navigate to the Utilities section within your WP Engine account and look for the Redirect Bots setting.

Disabling it should resolve this issue, but, it’s a good idea to speak with WP Engine support first to see if there are any options for removing the redirect specifically for Google’s Proxy Server requests.

 

Code Snippets

Note: This is a Developer level doc provided as guidance. We are unable to dispense advice or review code under our Support Policy.

Scanning barcodes results in a ‘permission denied’ error

If you are getting a ‘permission denied’ error when you attempt to scan a barcode, as of v1.1 you will see one of the following two error messages:

Security check failed

In this case, the security token (also known as a ‘nonce’) is not being checked correctly. This will most likely be due to how your server is set up, so if you get this error then adding the following snippet to your theme’s functions.php file will disable the nonce check:

You do not have sufficient permissions to scan barcodes

In this case the user you are logged in as does not have permission to scan barcodes. The default permissions required are that the user has the ‘manage_woocommerce’ capability, but you can change this to anything you want (or even make it different per user). If you get this error when you don’t think you should then adding the following snippet to your theme’s functions.php file will enable scanning permissions for all users (but you can edit it to process any requirements you like):

/*
 * Snippet to fix No Sufficient Permission To Scan Barcodes Error.
 * Code goes in the functions.php file in your theme.
*/
add_filter( 'woocommerce_order_barcodes_scan_permission', 'modify_woocommerce_order_barcodes_scan_permission' );
function modify_woocommerce_order_barcodes_scan_permission( $has_permission ) {
  // Do any required permission checks here
  $has_permission = true;
  return $has_permission;
}

Manual Output / Display of Barcode

Use the following PHP to output an order’s barcode anywhere:

/*
 * Snippet to display Order Barcodes anywhere in your site. 
 * Just copy the PHP Snippet to your template, and it will be displayed over there.
*/
echo WC_Order_Barcodes()->display_barcode($order_id);

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article