Jump to content

[Free module] Customer form address and phone number validation for PrestaShop 8+


Daresh

Recommended Posts

Hi!

Here is a simple module that will allow you to apply additional validation to customer address fields.

image.png.16a7c1fdc05d6f1b9c980773ce385870.png

In the first version it works like this:
1. You can validate the phone number using the libphonenumber library. It's a code based on how Google validates phone numbers on Android system, so quite a fancy tool. It works this way:
 - if the phone number has a country prefix (+XX), it is validated according to the rules for prefixed country
 - if the phone number does not have a country prefix, it is validated according to rules for the selected country in the form

2. You can validate the address1 field using a given (configurable) regular expression. The default one is actually quite simple and all it does is assuring that the address contains at least two letters and a number anywhere. It's mainly to make sure your customers will not omit home number in the address. Of course it's not perfect, but address validation is a hard task, that's why you can always customize the regular expression to your needs.

The module supports PrestaShop 8+ mainly because I am using the "lite" version of the libphonenumber library, which is quite new and requires PHP 8 to run.

After installing the module, you can adjust the error messages using the standard PrestaShop translation panel.

Looking forward to your comments and tests! 🙂

gmadmitter_1_0_0.zip

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Nie działa mi nie da się zainstalować w Prestaschop :

 

w klasach/ ConfigurationTest.php (linia 252)

            return false;

        }

        closedir($dh);

        $dummy = rtrim($dir, '\\/') . DIRECTORY_SEPARATOR . uniqid();

        if (@file_put_contents($dummy, 'test')) {

            @unlink($dummy);

            if (!$recursive) {

                return true;

            }

        } elseif (!is_writable($dir)) {

Link to comment
Share on other sites

  • 6 months later...
  • 4 weeks later...

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