Jump to content

Edit History

periwinkle_fr

periwinkle_fr


I forgot the \ before \Validate in order to make it work.

There is no way to override the validation regex mask provided in the src/Core/Domain/Customer/ValueObject/FistName.php and src/Core/Domain/Customer/ValueObject/lastName.php files.

Some people advised to alter those files :

but, it's not a good idea because changes could be overwrited in case of core update.

Instead of that, the validation process should use the Validate::isCustomerName() function to check is the field is valid or not.

I tryed to do it without altering the core by overriding the service "prestashop.core.form.identifiable_object.data_handler.customer_form_data_handler" like this 

https://devdocs.prestashop.com/1.7/modules/concepts/services/

Changing AddCustomerCommand class, EditCustomerCommand class, and finally FirstName and LastName classes 

It worked for the frontend but crashes the Backend with this error : 

Attempted to load class "CustomerFormDataHandler" from namespace "Pwk\PwkCustomer".
Did you forget a "use" statement for "PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CustomerFormDataHandler"?

Is there a way to manage this ? Or an update of these classes should be possible 

Simply changing 

$matchesFirstNamePattern = preg_match('/^[¤|]*$/u', stripslashes($firstName));

by 

$matchesFirstNamePattern = \Validate::isCustomerName($firstName));

Best regards,

periwinkle_fr

periwinkle_fr

There is no way to override the validation regex mask provided in the src/Core/Domain/Customer/ValueObject/FistName.php and src/Core/Domain/Customer/ValueObject/lastName.php files.

Some people advised to alter those files :

but, it's not a good idea because changes could be overwrited in case of core update.

Instead of that, the validation process should use the Validate::isCustomerName() function to check is the field is valid or not.

I tryed to do it without altering the core by overriding the service "prestashop.core.form.identifiable_object.data_handler.customer_form_data_handler" like this 

https://devdocs.prestashop.com/1.7/modules/concepts/services/

Changing AddCustomerCommand class, EditCustomerCommand class, and finally FirstName and LastName classes 

It worked for the frontend but crashes the Backend with this error : 

Attempted to load class "CustomerFormDataHandler" from namespace "Pwk\PwkCustomer".
Did you forget a "use" statement for "PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CustomerFormDataHandler"?

Is there a way to manage this ? Or an update of these classes should be possible 

Simply changing 

$matchesFirstNamePattern = preg_match('/^[¤|]*$/u', stripslashes($firstName));

by 

$matchesFirstNamePattern = Validate::isCustomerName($firstName));

Best regards,

×
×
  • Create New...