Using the Product Reference Number as a Barcode

Hello,

I want to use Reference Number as a Barcode value. Is there a any way to auto fill to barcode value? Thank you.

Hi,
if you want to have the ref as a barcode then that is possible via javascript…

You have to edit the source ~htdocs\product\card.php
Search for

		print dol_get_fiche_head('');

		print '<table class="border centpercent">';

		if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {

and insert the following code after the “{” :

			print '<script type="text/javascript">
			$(document).on("input", "#ref", function () {
				var new_qrcode = $("#ref").val();
				$("#barcode").val(new_qrcode); 
			});			
			</script>';	

As a result, the barcode is automatically filled in when the product reference is entered during new product creation.

Thanks for your help but it is not work.

My code is

print dol_get_fiche_head('');

		print '<table class="border centpercent">';

		if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
			
				print '<script type="text/javascript">
			$(document).on("input", "#ref", function () {
				var new_qrcode = $("#ref").val();
				$("#barcode").val(new_qrcode); 
			});			
			</script>';	
			
			print '<tr>';
			$tmpcode = '';
			
			if (!empty($modCodeProduct->code_auto)) {
				$tmpcode = $modCodeProduct->getNextValue($object, $type);
			}

We use it in Version 17.0.2 without problems
Please check if you have set the global variable PRODUCT_GENERATE_REF_AFTER_FORM

And you can also debug the javascript with your browser tools to see if the script is triggered.