Jump to content

Disable the EAN control function


alextn

Recommended Posts

Hi everyone, Prestashop 1.7. I need to modify for reasons I am not explaining the isEan13 function so that in the EAN 13 field letters and numbers can be entered without any control. I opened the classes / validate / validate.php file and modified the isEan13 function like this:


    public static function isEan13 ($ ean13)
    {
      return is_string ($ ean13);
    }


Entering numbers all ok, entering text letters, I always get the error This value is not valid. Any help please?  PS 
cash emptied
Edited by selectshop.at
mass capital letters on title removed (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
  • Members
  •  0
  • 21 messaggi

 

Solution:

//////////////////////////////////////////////////////////////////////

make the following changes

FILE: classes/Validate.php

public static function isEan13($ean13)
{
return !$ean13 || preg_match('/^[0-9]{0,13}$/', $ean13);
}

it becomes

public static function isEan13($ean13)
{
return !$ean13 || preg_match('/^[a-zA-Z0-9]{0,13}$/', $ean13);
}

//////////////////////////////////////////////////////////////////////


FILE: src\PrestaShopBundle\Form\Admin\Product/ProductOptions.php

  ->add('ean13', FormType\TextType::class, [
                'required' => false,
                'error_bubbling' => true,
                'label' => $this->translator->trans('EAN-13 or JAN barcode', [], 'Admin.Catalog.Feature'),
                'constraints' => [
                    new Assert\Regex('/^[0-9]{0,13}$/'),
                ],
                'empty_data' => '',
            ])

 

it becomes

  ->add('ean13', FormType\TextType::class, [
                'required' => false,
                'error_bubbling' => true,
                'label' => $this->translator->trans('EAN-13 or JAN barcode', [], 'Admin.Catalog.Feature'),
                'constraints' => [
                    new Assert\Regex('/^[a-zA-Z0-9]{0,13}$/'),
                ],
                'empty_data' => '',
            ])

//////////////////////////////////////////////////////////////////////

Edited by alextn (see edit history)
Link to comment
Share on other sites

  • 9 months later...
  • 1 year later...

Hi,

I'm on ps 1.7.7.5, I need to use a 14 numbers EAN code

1) I made changes on files

 src\PrestaShopBundle\Form\Admin\Product/ProductOptions.php
src\PrestaShopBundle\Form\Admin\Product/ProductCombination.php
FILE: classes/Validate.php

2) I've adapted the fieldsize in the database

3) I Cleared the cache

but doesn't work

do i have to do something else?

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...