Jump to content

SIRET from "optional" to "required" in sign-in form PS 1.7


Recommended Posts

Hello,

 

I have been reading this being possible on PS 1.6, I would like to get it on PS 1.7, please help.

 

Have been trying this way:

 

 

1.  Line 189 - classes/Customer.php: 

                'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret', 'required' => true, 'size' => 60),

 

 

2.  line 523 - controllers/admin/AdminCustomersController.php:

            $this->fields_form['input'][] = array(

                'type' => 'text',

                'label' => $this->trans('SIRET', array(), 'Admin.OrdersCustomers.Feature'),

                'name' => 'siret',

                'required' => true

 

 

3. As signing-in a new user (SIRET code being OK) I get this error:

 

 
[PrestaShopException]
 
Property Customer->siret is empty
at line 915 in file classes/ObjectModel.php


910.             }
911. 
912.             $message = $this->validateField($field, $this->$field);
913.             if ($message !== true) {
914.                 if ($die) {
915.                     throw new PrestaShopException($message);
916.                 }
917.                 return $error_return ? $message : false;
918.             }
919.         }
920. 


    ObjectModelCore->validateFields - [line 248 - classes/ObjectModel.php]
    ObjectModelCore->getFields - [line 489 - classes/ObjectModel.php]
    ObjectModelCore->add - [line 261 - classes/Customer.php] - [2 Arguments]
    CustomerCore->add - [line 447 - classes/ObjectModel.php] - [2 Arguments]
    ObjectModelCore->save - [line 189 - classes/form/CustomerPersister.php]
    CustomerPersisterCore->create - [line 61 - classes/form/CustomerPersister.php] - [2 Arguments]
    CustomerPersisterCore->save - [line 133 - classes/form/CustomerForm.php] - [3 Arguments]
    CustomerFormCore->submit - [line 46 - controllers/front/AuthController.php]
    AuthControllerCore->initContent - [line 201 - classes/controller/Controller.php]
    ControllerCore->run - [line 366 - classes/Dispatcher.php]
    DispatcherCore->dispatch - [line 28 - index.php]
 

 

 

Thank you

Regards

Link to comment
Share on other sites

Poor me !

 

I missed the most important:

 

For anyone interested, I got it this way:

 

/classes > Form > CustomerFormatter.php (sign-in form)
            $format['siret'] = (new FormField)
                ->setName('siret')
                ->setType('text')
                ->setLabel($this->translator->trans(
                    // Please localize this string with the applicable registration number type in your country. For example : "SIRET" in France and "Código fiscal" in Spain.
                    'Identification number', [], 'Shop.Forms.Labels'
                ))
                ->setRequired(true)
             ;
 
/classes > Customer.php (for customers accounts page)
                'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret', 'required' => true),
 
classes > Validate.php (Switch to a new validation system replacing the default French SIRET)
 
 
Hope it helps  :)
Edited by Malemi (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 8 months later...
  • 5 months later...
  • 10 months later...
On 3/9/2017 at 5:13 PM, Malemi said:

Poor me !

 

I missed the most important:

 

For anyone interested, I got it this way:

 

/classes > Form > CustomerFormatter.php (sign-in form)
            $format['siret'] = (new FormField)
                ->setName('siret')
                ->setType('text')
                ->setLabel($this->translator->trans(
                    // Please localize this string with the applicable registration number type in your country. For example : "SIRET" in France and "Código fiscal" in Spain.
                    'Identification number', [], 'Shop.Forms.Labels'
                ))
                ->setRequired(true)
             ;
 
/classes > Customer.php (for customers accounts page)
                'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret', 'required' => true),
 
classes > Validate.php (Switch to a new validation system replacing the default French SIRET)
 
 
Hope it helps  :)

Thank you..!
You have solved my same problem 😁

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...