Anes Posted August 17, 2009 Share Posted August 17, 2009 Hello Pals, I am a Newbie Programmer in Prestashop . Pal, I need to create a Module in which primarily I need to add some Form fields in user Registration page in Front Office .... The url of same in localhost is like http://localhost/prestashopNEW/authentication.php?back=my-account.php. I need to add one text field with name "Identification Fiscal" and four other checkboxes for select some options. I plan to add that additional form details go to another table that has connection with "customer" table in prestashop by it's P.K(Primary Key) "id_customer". But my problem is how to implement these form fields without edit the template related to my-account.php , with the usage of module .How I can do same using "Module". my another Problem is How to create that new Database Table on module installation itself .pls Give a quick reply with some Code snippet.... With Bunch of thanks Bye Anes Link to comment Share on other sites More sharing options...
crunch Posted October 20, 2009 Share Posted October 20, 2009 I know its been a couple of months since any reply, but for the benefit of others who may have this or a similar issue, please see:http://www.prestashop.com/forums/viewthread/13859/help_configuration___use/solved_adding_new_fields_to_new_accountFollowing the ideas in this post, I altered the main registration information by changing the following files:/themes//authentication.tpl /classes/Customer.php/admin/tabs/AdminCustomers.phpAnd also adding the new column in the database table 'ps_customers'This added a 'referral code' to my site, which was entered only at registration, but was viewable and editable in the back end. Link to comment Share on other sites More sharing options...
darqor Posted May 19, 2011 Share Posted May 19, 2011 what u mean under `referral code` ?????????thank you Link to comment Share on other sites More sharing options...
crunch Posted May 19, 2011 Share Posted May 19, 2011 'referral code' was the name of the new text field I needed to be included in my site registration process. It's whatever you want. Link to comment Share on other sites More sharing options...
otakarw Posted June 10, 2011 Share Posted June 10, 2011 To add column into databaase during installation of module you neet to execute this code:"addind company ID and Tax ID into ps_adress table" class CompanyID extends Module { public function __construct() { $this->name = 'companyid'; //directory name $this->tab = 'billing_invoicing'; $this->version = '1.0'; $this->author = 'xxx'; parent::__construct(); $this->displayName = $this->l('Company ID\'s'); $this->description = $this->l('This module extends information about customer with Company ID and Tax ID. '); $this->confirmUninstall = $this->l('Are you sure to uninstall this module? Collect and display information about customer\'s Company ID and Tax ID!'); } public function install() { /* Install and register on hook */ if (!parent::install() OR !$this->registerHook('createAccountForm') OR !$this->registerHook('customerAccount') OR !$this->registerHook('adminCustomers')) return false; /* Setting database adding column */ if (!Db::getInstance()->Execute('SELECT company_id from `'._DB_PREFIX_.'address`')) { if (!Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'address` ADD `company_id` varchar(16) NULL AFTER `phone_mobile`')) return false; } if (!Db::getInstance()->Execute('SELECT tax_id from `'._DB_PREFIX_.'address`')) { if (!Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'address` ADD `tax_id` varchar(16) NULL AFTER `company_id`')) return false; } /* Set configuration - creates value in ps_modules table */ Configuration::updateValue('COMPANY_ID_MODULE_ENABLED', 1); return true; } public function uninstall() { .... } .... Link to comment Share on other sites More sharing options...
otakarw Posted June 10, 2011 Share Posted June 10, 2011 To add whole database, execute inside install() function this condition: /* Create Table */ if (!Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'paypal_order` (`id_order` int(10) unsigned NOT NULL auto_increment, `id_transaction` varchar(255) NOT NULL, PRIMARY KEY (`id_order`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8')) return = false; //returns false if Db::getInstance.. returns true =(!(false=error)) in other case is skipped Link to comment Share on other sites More sharing options...
otakarw Posted June 10, 2011 Share Posted June 10, 2011 To solve the issue that form is hardcoded in core files you can inj elements of your form (I did not come further because doing this takes much more time than edit core)use function appendBeforejust sniplet example: var newP = document.createElement("p"); var txt = 'Kilroy was here.'; var newT = document.createTextNode(txt); newP.appendChild(newT); var p2 = document.getElementsByTagName('p')[1]; p2[removed].insertBefore(newP,p2); You have to replace submit form button by our button by new element (submit button) d.removeChild(X); document.createElement(Y); more here: http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/and then submit form with cURL or fopen to file url=/modules/your_module/your_code.php - this form should contain altered authentification.php class from core. More here http://www.html-form-guide.com/php-form/php-form-submit.htmllast issue to redirect via cURL to /my-account.php or /order.php?step=1 so it means that is too much complicated Link to comment Share on other sites More sharing options...
Recommended Posts