minanj12 Posted September 17, 2017 Share Posted September 17, 2017 Hello, When a customers tries to checkout they get an error after they type the address. It seems like it's throwing this error because the customer isn't entering a country. The problem is it doesn't ask for a country. It just asks for a state, zip code etc. I sell only for U.S. customers so I don't really care if they enter the country or not. Regardless I want this to work. Can you someone help? Thanks in advance. [PrestaShopException]Property Address->id_country is empty.at line 944 in file classes/ObjectModel.php 939. }940.941. $message = $this->validateField($field, $this->$field);942. if ($message !== true) {943. if ($die) {944. throw new PrestaShopException($message);945. }946. return $error_return ? $message : false;947. }948. }949. ObjectModelCore->validateFields - [line 272 - classes/ObjectModel.php] ObjectModelCore->getFields - [line 518 - classes/ObjectModel.php] ObjectModelCore->add - [line 174 - classes/Address.php] - [2 Arguments] AddressCore->add - [line 476 - classes/ObjectModel.php] - [2 Arguments] ObjectModelCore->save - [line 76 - classes/form/CustomerAddressPersister.php] CustomerAddressPersisterCore->save - [line 162 - classes/form/CustomerAddressForm.php] - [2 Arguments] CustomerAddressFormCore->submit - [line 111 - classes/checkout/CheckoutAddressesStep.php] CheckoutAddressesStepCore->handleRequest - [line 57 - classes/checkout/CheckoutProcess.php] - [1 Arguments] CheckoutProcessCore->handleRequest - [line 201 - controllers/front/OrderController.php] - [1 Arguments] OrderControllerCore->initContent - [line 205 - classes/controller/Controller.php] ControllerCore->run - [line 379 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 28 - index.php] Link to comment Share on other sites More sharing options...
bellini13 Posted September 19, 2017 Share Posted September 19, 2017 What version of Prestashop? Be specific Are you using the standard theme included with Prestashop, or a custom theme? If you are using a custom theme, then contact your theme provider for support If you are using the standard theme, did you make changes to it? The standard theme will always ask for the address Country, as it is a required field. Link to comment Share on other sites More sharing options...
Yoan Consultin Web Posted September 27, 2017 Share Posted September 27, 2017 Hello, I have a similary problem with a customer on prestashop 1.7.2.2., have you got a solution to this problem? Thanks for your help Yoan. Link to comment Share on other sites More sharing options...
bellini13 Posted September 28, 2017 Share Posted September 28, 2017 Hello, I have a similary problem with a customer on prestashop 1.7.2.2., have you got a solution to this problem? Thanks for your help Yoan. Are you using the standard theme included with Prestashop, or a custom theme? Link to comment Share on other sites More sharing options...
Yoan Consultin Web Posted September 28, 2017 Share Posted September 28, 2017 Hello, My client uses a theme that he has customized himself and how to see if he has spawned an error. For my part I am an integrator and not a developer so I lose a lot of time since Monday on this worry. I just did a test with the shopping cart of a customer who did not order, it marks that the address can not be delivered, while his country and zone are correct, but I think that again is due to the address that does not pass. There is currently this error message as well. Frontcontroller::init - Cart cannot be loaded or an order has already been placed using this cart Frontcontroller::init - Cart cannot be loaded or an order has already been placed using this cart Link to comment Share on other sites More sharing options...
bellini13 Posted September 29, 2017 Share Posted September 29, 2017 That message is just a warning, doesn't actually cause an issue Well, it would seem that your client likely broke something in the theme, by not properly capturing the country for the address. Not really an issue that can be solved in a forum post, someone is going to have to dive into the code and see what was removed Link to comment Share on other sites More sharing options...
Yoan Consultin Web Posted September 29, 2017 Share Posted September 29, 2017 Ok and can you help me if i give you an private access on his server ftp, mysql, and backoffice? Thanks for your return, Yoan Link to comment Share on other sites More sharing options...
Yoan Consultin Web Posted September 29, 2017 Share Posted September 29, 2017 Hello, Many thanks for your return. My client has apparently changed the addresses.tpl file, this can be the source of the problem. Comparing the two files the only differences are at this level: In the "cakelicious theme" there is a hook more ... {hook h = "displayCartRuleAddress"} {if $ use_same_address &&! $ cart.is_virtual} Classic Version {if $ use_same_address &&! $ cart.is_virtual} For the position of the button, nothing serious here, o) The class of the last button is different. Here the version "theme cakelicious" {if! $ form_has_continue_button} <div class = "clearfix"> <button type = "submit" class = "btn btn-primary continue pull-xs-right" name = "confirm-addresses" value = "1"> {l s = 'Continue' d = 'Shop.Theme.Actions'} </ Button> </ Div> {/ If} The class of the last button is different. Here the version "Classic" {if! $ form_has_continue_button} <div class = "clearfix"> <button type = "submit" class = "btn-primary continuous float-xs-right" name = "confirm-addresses" value = "1"> {l s = 'Continue' d = 'Shop.Theme.Actions'} </ Button> </ Div> {/ If} If an developer can give me a helping hand because I admit to rowing for 5 days on this problem and do not know how to get out, I can transmit ftp, mysql and backoffice access in mp if necessary to access the site test in order to look at this. In thanking you in advance, most cordially, Yoan. Link to comment Share on other sites More sharing options...
bellini13 Posted September 30, 2017 Share Posted September 30, 2017 For starters, I would suggest installing a free theme and activate it. If the issue was caused by the client changing the theme, then installing a new theme should fix the issue. If it doesn't fix the issue, then you would need to start going through the server side code looking for changes, which can include changes to modules, or perhaps the addition of a custom module that is interfering with customer/address creation Link to comment Share on other sites More sharing options...
Yoan Consultin Web Posted October 1, 2017 Share Posted October 1, 2017 Hello, Sorry for my late return, so the problem is random and does not happen every time, that's what let me think more of a coding error in the modifications of the theme, than a module problem. Is there a tool to analyze the files of a theme see if there are no code errors in it? Regards, Link to comment Share on other sites More sharing options...
ITIS-Commerce.com Posted April 18, 2018 Share Posted April 18, 2018 Hi, This a bug from prestashop. Change the file \classes\form\CustomerAddressPersister.php by the one attached CustomerAddressPersister.zip Link to comment Share on other sites More sharing options...
Chikane Posted April 23, 2018 Share Posted April 23, 2018 On 18/4/2018 at 11:28 AM, ITIS-Commerce.com said: Hi, This a bug from prestashop. Change the file \classes\form\CustomerAddressPersister.php by the one attached CustomerAddressPersister.zip Thank you sooo much! That worked for me! Link to comment Share on other sites More sharing options...
Lily-Fu Posted May 6, 2018 Share Posted May 6, 2018 (edited) Dosen't work for me, still have this error message.... if someone has an idea Edited May 6, 2018 by Lily-Fu too much images (see edit history) Link to comment Share on other sites More sharing options...
mnick Posted May 7, 2018 Share Posted May 7, 2018 I have the same problem on PS 1.7.3.0 Link to comment Share on other sites More sharing options...
Brenda Posted August 24, 2018 Share Posted August 24, 2018 I have the same problem, I need a solution Link to comment Share on other sites More sharing options...
Wing Tip Posted September 27, 2018 Share Posted September 27, 2018 I have select default setting for the country and now working 1 Link to comment Share on other sites More sharing options...
husein522 Posted July 18, 2019 Share Posted July 18, 2019 (edited) Hi, I am getting same error after upgrading to php 7. I am using prestashop version 1.6. in 1.6 version there is no such class as form\CustomerAddressPersister.php thanks, husein Edited July 18, 2019 by husein522 (see edit history) Link to comment Share on other sites More sharing options...
husein522 Posted July 18, 2019 Share Posted July 18, 2019 this is the error [PrestaShopException] Property Address->id_country is empty at line 909 in file classes/ObjectModel.php 904. } 905. 906. $message = $this->validateField($field, $this->$field); 907. if ($message !== true) { 908. if ($die) { 909. throw new PrestaShopException($message); 910. } 911. return $error_return ? $message : false; 912. } 913. } 914. ObjectModelCore->validateFields - [line 246 - classes/ObjectModel.php] 241. * @return array All object fields 242. * @throws PrestaShopException 243. */ 244. public function getFields() 245. { 246. $this->validateFields(); 247. $fields = $this->formatFields(self::FORMAT_COMMON); 248. 249. // For retro compatibility 250. if (Shop::isTableAssociated($this->def['table'])) { 251. $fields = array_merge($fields, $this->getFieldsShop()); ObjectModelCore->getFields - [line 487 - classes/ObjectModel.php] 482. 483. // Database insertion 484. if (Shop::checkIdShopDefault($this->def['table'])) { 485. $this->id_shop_default = (in_array(Configuration::get('PS_SHOP_DEFAULT'), $id_shop_list) == true) ? Configuration::get('PS_SHOP_DEFAULT') : min($id_shop_list); 486. } 487. if (!$result = Db::getInstance()->insert($this->def['table'], $this->getFields(), $null_values)) { 488. return false; 489. } 490. 491. // Get object id in database 492. $this->id = Db::getInstance()->Insert_ID(); ObjectModelCore->add - [line 173 - classes/Address.php] - [2 Arguments] 168. /** 169. * @see ObjectModel::add() 170. */ 171. public function add($autodate = true, $null_values = false) 172. { 173. if (!parent::add($autodate, $null_values)) { 174. return false; 175. } 176. 177. if (Validate::isUnsignedId($this->id_customer)) { 178. Customer::resetAddressCache($this->id_customer, $this->id); AddressCore->add - [line 445 - classes/ObjectModel.php] - [2 Arguments] 440. * @return bool Insertion result 441. * @throws PrestaShopException 442. */ 443. public function save($null_values = false, $auto_date = true) 444. { 445. return (int)$this->id > 0 ? $this->update($null_values) : $this->add($auto_date, $null_values); 446. } 447. 448. /** 449. * Adds current object to the database 450. * ObjectModelCore->save - [line 212 - controllers/front/AddressController.php] 207. $this->ajaxDie(Tools::jsonEncode($return)); 208. } 209. } 210. 211. // Save address 212. if ($result = $address->save()) { 213. // Update id address of the current cart if necessary 214. if (isset($address_old) && $address_old->isUsed()) { 215. $this->context->cart->updateAddressId($address_old->id, $address->id); 216. } else { // Update cart address 217. $this->context->cart->autosetProductAddress(); AddressControllerCore->processSubmitAddress - [line 107 - controllers/front/AddressController.php] 102. * @see FrontController::postProcess() 103. */ 104. public function postProcess() 105. { 106. if (Tools::isSubmit('submitAddress')) { 107. $this->processSubmitAddress(); 108. } elseif (!Validate::isLoadedObject($this->_address) && Validate::isLoadedObject($this->context->customer)) { 109. $_POST['firstname'] = $this->context->customer->firstname; 110. $_POST['lastname'] = $this->context->customer->lastname; 111. $_POST['company'] = $this->context->customer->company; 112. } AddressControllerCore->postProcess - [line 178 - classes/controller/Controller.php] 173. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) { 174. $this->setMedia(); 175. } 176. 177. // postProcess handles ajaxProcess 178. $this->postProcess(); 179. 180. if (!empty($this->redirect_after)) { 181. $this->redirect(); 182. } 183. ControllerCore->run - [line 367 - classes/Dispatcher.php] 362. if (isset($params_hook_action_dispatcher)) { 363. Hook::exec('actionDispatcher', $params_hook_action_dispatcher); 364. } 365. 366. // Running controller 367. $controller->run(); 368. } catch (PrestaShopException $e) { 369. $e->displayMessage(); 370. } 371. } 372. DispatcherCore->dispatch - [line 28 - index.php] 23. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 24. * International Registered Trademark & Property of PrestaShop SA 25. */ 26. 27. require(dirname(__FILE__).'/config/config.inc.php'); 28. Dispatcher::getInstance()->dispatch(); Link to comment Share on other sites More sharing options...
malcolm123 Posted May 4, 2020 Share Posted May 4, 2020 On 4/18/2018 at 11:28 AM, ITIS-Commerce.com said: Hi, This a bug from prestashop. Change the file \classes\form\CustomerAddressPersister.php by the one attached CustomerAddressPersister.zip I had the same problem and this file has solved it for me. Thank you. The only thing to change is on line 73 and 74 What do you think of this other modification?https://github.com/PrestaShop/PrestaShop/pull/10373/files Just adding $ address-> save (); I have not tried this but would it be correct? Thank you. 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