Koha How-To

Meet the Scanned Barcode Prefixer Plugin

What does the prefixer do?

The Scanned Barcode Prefixer plugin allows libraries to automatically create and read prefixed barcodes. For patron or item creation, the plugin automatically adds digits to the beginning of the card number/barcode that is entered into the new record. During circulation - when scanning a library card for checkout, for instance, or checking in a book - it will add branch-specific digits to what is scanned if the prefix isn't physically printed.

Who should consider the prefixer?

The prefixer can benefit libraries in a number of ways:

Joining a consortium: If a library is joining a consortium, they may need to match the consortium's digit length for item or patron barcodes - for instance, the consortium may require a 10-digit barcode, but the new library's items may have 8-digit barcodes. The prefixer can automatically prepend digits to the start of the new member's barcodes so that staff don't have to modify thousands of items by hand.

Easily distinguish location: Libraries with multiple locations/branches may want to easily distinguish a patron or item's home library without having to open each record. The prefixer will prepend branch-specific digits to make it clear with a quick look at the card number/barcode.

Shared barcodes: Single-location libraries can benefit, too! Some libraries may use the same stock of barcodes to create patron card numbers and item barcodes, which can slow down circulation if a patron barcode is scanned where an item barcode is expected (or vice versa). The prefixer can automatically add patron- and item-specific digits so that Koha knows which type of barcode is being scanned.


Here is an example of a fully-configured Scanned Barcode Plugin:

Here's how each piece breaks down.

1: The total length of each barcode type, including prefixed digits

2: Each library's code (from Administration--Libraries)

3: The digits prepended to item barcodes and patron barcode/card numbers, respectively

If a branch is configured with a tilde (~) or “”, or is left out of the plugin configurations, 0s will be added to its item and patron barcodes (if necessary) to reach the required number of digits.

Creating barcodes

The plugin adds digits based on the library at which the staff member creating the barcode is logged in, not the item or patron's home library.

When a new item barcode is created, the numbers after item_prefix for the logged-in library will be automatically added before the barcode that they scan or enter into 952$p, or to the barcode generated automatically by AutoBarcode. Libraries do not need to manually add their branch's digits to the field.

Similarly, when a new patron is created, the logged-in branch's prefix will be added to the start of the card number that is scanned/entered into 'Card number'. If the system preference AutoMemberNum is enabled, the prefix will be added to the automatically-generated card number.

Although they won't be visible when you're creating the item/patron record, you will see the added digits when you view the record after saving. For example:

Printed barcodes can include prefixes, but they do not have to depending on your library's circumstances and policies. This is discussed in more detail below.

Note the following:
If the 'basic' barcode plus library-specific prefix would add up to more digits than set by item_barcode_length or patron_barcode_length, the prefix will not be added. For instance, using the example above with item_barcode_length limited to 10 digits: if I'm logged in at M and create an item with the 10-digit 'basic' barcode of 1234567899, 301 will not prepend. Similarly, if I'm logged in at N and my automatically-generated 'basic' card number for a new patron is 98765432 (8 digits), 211 will not prepend.

On the other hand, if the 'basic' barcode plus prepended digits are fewer than the number specified in item_barcode_length or patron_barcode_length, the plugin will add 0s between the prefix and the 'basic' number to reach the required number of digits. So if my 'basic' barcode at E is 23456, the prefixed barcode will be 1010023456 - the two zeros after the 101 prefix create a 10-digit barcode as required by item_barcode_length.


Searching for items:
The full barcode including prefix is required when searching for items by barcode, regardless of the library at which you're logged in to search. This is true whether you are searching by keyword or barcode, and for both the multi-purpose search bar and in advanced search.

Searching for patrons:
For patrons, you can successfully search using the multi-purpose search bar or the full patron module using the full prefixed number or the 'basic' card number without branch-specific digits added.

If you search with the prefix, you will go straight to the exact record.

If you search without the prefix and patrons at multiple branches share the same 'basic' digits, all patrons with that 'basic' string will be part of the results list regardless of where you're logged in (if staff permissions allow):


Scanning the patron's card:
When you're scanning a patron barcode for checkout, the plugin will look for a prefix in what you've scanned. If one isn't found, it will automatically affix the one configured for the library where you are logged in.

For instance, patron L. Bates was created at East Branch (E). Their 'basic' card number is 58543, and their full number with prefix is 11158543. If I am logged in at West and scan the full number for checkout, Koha brings me to their checkout tab:

If I scan the 'basic' number at West, though, Koha recognizes that there is no prefix attached and adds the one configured for West since that's where I'm logged in:

If I scan the 'basic' number at East, Koha adds the E prefix and successfully finds the patron.

Scanning the item(s):
Scanning item barcodes for checkouts, renewals, and check-ins works the same way. If a full item barcode (prefix included) is scanned for checkout, renewal, or check-in, Koha will recognize the barcode and proceed with the transaction regardless of logged-in branch. For instance, this item was created at Main (M) so it has a 301 prefix. If it is returned at East and the full barcode is scanned, it successfully checks in:

But if I try to return that item at East with the 'basic' barcode, Koha will add the 101 prefix for E and fail to find the item:

Accordingly, checking in the item at Main by scanning only the 'basic' barcode will successfully identify and return the item, since the 301 Main prefix will be automatically added by the plugin.

Should prefixes be physical?

Whether your printed item and patron barcodes should include the prefix will depend on your circulation policies and why your library is using the plugin.

Print when:
Systems or consortia that share items between branches/libraries or where patrons registered at one location can check items out from another will want the prefixes to be printed. Otherwise, items will not successfully check in or out anywhere other than their home branch, and patrons won't be able to use their physical card anywhere other than their registered branch.

Printing optional:
In general, printing prefixes is optional for any circumstance where items and patrons are not shared between locations/branches.

If, for instance, the plugin is used to add digits to a new consortium member's barcodes and those patrons/items are not shared between libraries, the prefixes do not need to be (re-)printed for existing item/patron barcodes. They can be printed for new barcodes, but the plugin will successfully read barcodes for that location with and without the prefix.

No printing:
If a single-location library is using the same stock for patron and item barcodes and uses the plugin to more easily distinguish between the two, the question is moot since the barcodes are already printed.

Read more by Sara Brown

Tags barcode, plugins