Daresh Posted February 12, 2024 Share Posted February 12, 2024 Hi! Here is a simple module that will allow you to apply additional validation to customer address fields. 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.zipFetching info... 2 1 Link to comment Share on other sites More sharing options...
Karol_K_ Posted March 28, 2024 Share Posted March 28, 2024 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 More sharing options...
goldies Posted October 26, 2024 Share Posted October 26, 2024 IS IT AVAILABLE FOR ps 1.7? Link to comment Share on other sites More sharing options...
Daresh Posted October 26, 2024 Author Share Posted October 26, 2024 For 1.7 a different library needs to be used, what makes the module nearly 20MB and I can't post it to the forum. Link to comment Share on other sites More sharing options...
zyadyaaa Posted November 18, 2024 Share Posted November 18, 2024 Thanks for this module! BestRegard Link to comment Share on other sites More sharing options...
romimac Posted January 2 Share Posted January 2 Cześć Daresh, I'm trying to run this module on PrestaShop 8.2.0 (PHP 8.1.31) but without debug mode it's throwing me following error. If I'm in debug mode the module is working fine. I'm also using JPresta Cache plugin if it's important. [02-Jan-2025 11:27:55 Europe/Warsaw] PHP Fatal error: Uncaught Error: Class "libphonenumber\PhoneNumberUtil" not found in /home/xxx/modules/gmadmitter/gmadmitter.php:171 Stack trace: #0 /home/xxx/modules/pagecache/pagecache.php(3681): GmAdmitter->hookActionValidateCustomerAddressForm() #1 /home/xxx/override/classes/Hook.php(24): PageCache::execHook() #2 /home/xxx/classes/Hook.php(418): Hook::coreCallHook() #3 /home/xxx/classes/Hook.php(983): HookCore::callHookOn() #4 /home/xxx/classes/form/CustomerAddressForm.php(140): HookCore::exec() #5 /home/xxx/classes/form/CustomerAddressForm.php(149): CustomerAddressFormCore->validate() #6 /home/xxx/classes/checkout/CheckoutAddressesStep.php(95): CustomerAddressFormCore->submit() #7 /home/xxx/classes/checkout/CheckoutProcess.php(76): CheckoutAddressesStepCore->handleRequest() #8 /home/xxx/controllers/front/OrderController.php(252): CheckoutProcessCore->handleRequest() #9 /home/xxx/classes/controller/Controller.php(319): OrderControllerCore->initContent() #10 /home/xxx/classes/Dispatcher.php(510): ControllerCore->run() #11 /home/xxx/index.php(39): DispatcherCore->dispatch() #12 {main} thrown in /home/xxx/modules/gmadmitter/gmadmitter.php on line 171 Link to comment Share on other sites More sharing options...
Daresh Posted January 2 Author Share Posted January 2 Indeed it looks like the PageCache module tries to execute this hook, but I don't know Page Cache module very well to be able to tell more. Link to comment Share on other sites More sharing options...
romimac Posted January 2 Share Posted January 2 Developer of PageCache said that problem is connected to gmadmitter module and not cache module. Is there any change you could look at that? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now