diff --git a/README.md b/README.md index 580a302..e24f6d2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ # prestashop-phone-field-for-registration -module to add phone field for registration in prestashop 1.7 +this module allow to add phone field in registration form, you can use same module as template to create other fields + + +[![Github All Releases](https://img.shields.io/github/downloads/taoufiqaitali/prestashop-phone-field-for-registration/total.svg)]() +[![Twitter](https://img.shields.io/twitter/url?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Ftaoufiqaitali%2Fprestashop-phone-field-for-registration) + +![phone field for registration](docs/screenshot1.png) + +##Installation +1. download the archive from [GitHub](https://github.com/taoufiqaitali/prestashop-phone-field-for-registration/archive/master.zip) +2. rename prestashop-phone-field-for-registration-master zip and folder to **regphonefield** +3. install from prestashop backoffice like any other module +4. Clear cache and enjoy + +##To create other fields +1. Download repository +2. search "phone" and replace with your field name +3. Follow installation steps + diff --git a/docs/screenshot1.png b/docs/screenshot1.png new file mode 100644 index 0000000..35df7b5 Binary files /dev/null and b/docs/screenshot1.png differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..5423c88 --- /dev/null +++ b/index.php @@ -0,0 +1,35 @@ + +* @copyright 2007-2014 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..5fa52b5 Binary files /dev/null and b/logo.png differ diff --git a/override/classes/Customer.php b/override/classes/Customer.php new file mode 100644 index 0000000..b2d4b53 --- /dev/null +++ b/override/classes/Customer.php @@ -0,0 +1,21 @@ + self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 64); + parent::__construct($idStore, $idLang); + } + + +} \ No newline at end of file diff --git a/regphonefield.php b/regphonefield.php new file mode 100644 index 0000000..f051133 --- /dev/null +++ b/regphonefield.php @@ -0,0 +1,80 @@ +name = 'regphonefield'; + $this->tab = 'front_office_features'; + $this->version = '1.0.0'; + $this->author = 'Taoufiq Ait Ali'; + $this->need_instance = 0; + $this->bootstrap = true; + + parent::__construct(); + + $this->displayName = $this->l('phone field for registration'); + $this->description = $this->l('Add phone field to registration form.'); + $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); + } + public function install() + { + $result = true; + if (!parent::install() + || !$this->registerHook('additionalCustomerFormFields') + || !$this->registerHook('actionCustomerAccountAdd') + || !$this->registerHook('actionAdminCustomersListingFieldsModifier') + ) { + $result = false; + } + + $res =(bool)Db::getInstance()->execute( + 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `phone` varchar(64) NULL' + ); + + return $result; + } + + public function uninstall() + { + if (!parent::uninstall() + ) { + return false; + } + $res =(bool)Db::getInstance()->execute( + 'ALTER TABLE `'._DB_PREFIX_.'customer` DROP `phone`' + ); + return true; + } + + public function hookAdditionalCustomerFormFields($params) + { + $formField = new FormField(); + $formField->setName('phone'); + $formField->setType('text'); + $formField->setLabel($this->l('Phone')); + $formField->setRequired(true); + return array($formField); + } + + public function hookActionCustomerAccountAdd($params) + { + $customerId =$params['newCustomer']->id; + $phone= Tools::getValue('phone',''); + return (bool) Db::getInstance()->execute('update '._DB_PREFIX_.'customer set phone=\''.pSQL($phone)."' WHERE id_customer=".(int) $customerId); + } + public function hookActionAdminCustomersListingFieldsModifier($params) + { + $params['fields']['phone'] = array( + 'title' => $this->l('Phone'), + 'align' => 'center', + ); + } +}