webmonger Posted March 20, 2017 Share Posted March 20, 2017 I am adding custom field to address by overiding Address class: <?php class Address extends AddressCore { public $extrafield; public function __construct($id_address = null, $id_lang = null) { self::$definition['fields']['extrafield'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64); parent::__construct($id_address, $id_lang); } } Also I have modified the template to add the new input field. This scenario is working in PrestaShop 1.6, new input is saved in database. But in PrestaShop 1.7, the new input is not saved in database. Am I missing something here ? Thanks Link to comment Share on other sites More sharing options...
webmonger Posted March 20, 2017 Author Share Posted March 20, 2017 (edited) I think i found why in PrestaShop 1.7 the extrafield is not auto-inserted to database as in PrestaShop 1.6. In AddressController, postProcess: $this->address_form->fillWith(Tools::getAllValues()); The Tools::getAllValues() already contains all value submitted. But the address_form's fillWith only fill the field from the country's format address. In the end, it would be great if actionAddressSave is added to core Edited March 20, 2017 by webmonger (see edit history) Link to comment Share on other sites More sharing options...
changeyourlife Posted May 6, 2017 Share Posted May 6, 2017 I am adding custom field to address by overiding Address class: <?php class Address extends AddressCore { public $extrafield; public function __construct($id_address = null, $id_lang = null) { self::$definition['fields']['extrafield'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64); parent::__construct($id_address, $id_lang); } } Also I have modified the template to add the new input field. This scenario is working in PrestaShop 1.6, new input is saved in database. But in PrestaShop 1.7, the new input is not saved in database. Am I missing something here ? Thanks How does you modified your template for present your field? Link to comment Share on other sites More sharing options...
madkot Posted June 25, 2019 Share Posted June 25, 2019 Old topic.. In prestashop 1.7 this solution needed to add column 'extrafield' to address table in database. 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