How to Add Barcodes to a Drupal POS System

| Drupal
How to Add Barcodes to a Drupal POS System

An OSTraining member asked us about adding barcodes to a Drupal site. They wanted to use barcodes as part of a Point-of-sale (POS) system.

This ended up being a complex task. Several barcode modules are available, however many have not been well-maintained over the years.

After testing, I would not recommend using Drupal's Commerce POS module, unless you are already using Drupal Commerce. The number of module dependencies and dev versions needed to run Commerce POS does not give me a lot of confidence for stability.

Using the Drupal's Barcode module is a better option. This allows you to add barcodes as fields.

You will need the following modules :

If you go to the bottom of the Barcode project page you will see both a stable and dev release. The stable version hasn't updated for some time however the dev version has been recently updated and does appear to be working well.

Going down to the "fields" section of your modules page and you will see the barcode module and that you can enable it here. If you would like to enable examples for the barcode module go down to the "Other" section and you will see the option to enable "Barcode examples". I'm going to enable both modules in this tutorial.

Installing Drupal's barcode modules
  • Go to Configuration > Barcode.
  • On this page you can select where the barcodes that are generated are saved. You can also choose which font the barcodes should use.
The Drupal barcode configuration

Now that we have confirmed the barcode settings, let's add the functionality to our site.

  • Go to Structure > Content types > Manage fields 
  • Create the label for the field. In this example, I have called it "basic page barcode".
  • In the field type, select the dropdown and you should see "Barcode" as the first option available.
Drupal barcode field
  • Save the field.
  • This will bring you to a new page where you can define the field settings for the new barcode. As you can see from the image below, the Barcode modules give you access to a series of different barcode types:
Drupal barcode field settings

Now you have successfully added the barcode to the basic page, let's add a basic page so we can see a barcode on display.

  • Go to Add content > Basic page.
  • Enter 13 digits for the barcode. This field will only accept numbers.
  • Save the page, and your barcode will appear:
A Drupal barcode field added to a node

About the author

Daniel is a freelance web designer who works from the UK and is a keen user of drupal with a passion for Drupal 8.