The 12th digit for UPC code is optional for submission, since it can be calculated at the time of generation. However, when a user submits the barcode with 11 digits, the generator didn't calculate the 12 digit, instead put a 0 in front of the numbers.

This could be a problem of generator.

Comments

slip’s picture

In _ean13CheckDigit

There's:

// If the source message string is less than 12 characters long, we make it 12 characters
if(strlen($barnumber) <= 12 )
{
$barnumber = str_pad($barnumber, 13, "0", STR_PAD_LEFT); 
}

Does changing the '13' to '12' work?

skyredwang’s picture

Status: Active » Fixed

I wrote the validation before, but there was a bug that has prevented it working.

I committed the change, maybe you want to port it to 2.x.

in

function barcode_field($op, &$node, $field, &$items, $teaser, $page) 

change

if ($len!=0 && strlen(trim(check_plain($item['title']!=0))))

to

if ($len!=0 && strlen(trim(check_plain($item['title'])))!=0)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aCCa’s picture

Having similar problem with ean-13, in the function barcode_ean_check_digit in ean.inc

Seems that even the code is filled up with zeros in front correctly, the $csum_total variable is wrong and the function return the barcode + the checksum digit.

The problem is that it encode this (barcode + checksum_digit) to the image, generating a wrong barcode image.

aCCa’s picture

Problem a bit different.

Created specific bug report: http://drupal.org/node/1145074