This issue has been migrated from the Forge. Read the original ticket here.
Hi on new client upgrade we had issue where new address caused 500 error..either at checkout or via 'my account' 'add address'.
We solved issue from this stackoverflow thread
https://stackoverflow.com/questions/42413535/prestashop-1-7-unable-to-save-order-address
This solved the issue.
original error info
account creation, add address 500 errors.
to replicate, create new account then add new address. I originally had this issue when trying to check out and adding address...
[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)
{
946. return $error_return ? $message : false;
947. }
948. }
949.
ObjectModelCore->validateFields - [line 272 - classes/ObjectModel.php]
ObjectModelCore->getFields - [line 683 - classes/ObjectModel.php]
ObjectModelCore->update - [line 202 - classes/Address.php] - [1 Arguments]
AddressCore->update - [line 219 - classes/Address.php]
AddressCore->delete - [line 73 - 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]
add address via checkout or my account
This comment has been migrated from the Forge. Read the original comment here.
Je reproduis l'erreur apr猫s avoir supprim茅 le champ "Country:name" du format de l'adresse
This comment has been migrated from the Forge. Read the original comment here.
It looks like the error in the classes/Address.php line 305 function isUsed
I believe the following lines should be added to that function:
if(empty($this->id))
{ return false; }
This comment has been migrated from the Forge. Read the original comment here.
Hi el patron,
I manage to reproduce the issue with the last version : 1.7.2.4.
We will see how to fix it.
Best regards, Salma
This comment has been migrated from the Forge. Read the original comment here.
thanks Salma!
I used fix from stackovervlow but it may not be most elegant way to fix. I am happy to change client shop to your fix when ready.
Way to kick it's butt! We try to report more to help as we do client upgrades....
el
This comment has been migrated from the Forge. Read the original comment here.
As per Kostyantyn Bilous:
If ps_orders table contains records with id_address_delivery = 0 or id_address_invoice = 0 then any new registered user unable to add new address into their account.
It looks like the error in the classes/Address.php line 305 function isUsed
I believe the following lines should be added to that function:
if(empty($this->id))
{ return false; }
So although you closed down BOOM-4299 as a duplicate, it seems like there are two solutions here within two different files.
In my case, I am seeing exactly the same issue as described in BOOM-4299. Adding a new address when ps_order table contains a 0 in the two fields, you cannot add new address into their account.
Kostyantyn Bilous, can you paste the whole classes/Address.php IsUsed() function with your fix so that I can test as well? When you say add these two lines, I am not 100% sure where to add those two lines. Right now, IsUsed() looks like this in both my 1.7.1.2 and 1.7.2.0 installations where I am having this problem.:
/**
This comment has been migrated from the Forge. Read the original comment here.
As additional information, the fix on https://stackoverflow.com/questions/42413535/prestashop-1-7-unable-to-save-order-address by updating the classes\form\CustomerAddressPersister.php file with a simple 1 line to add seemed to do the trick for me:
$address->id_customer = $this->customer->id;
$address->save(); // <-- Add this
Scroll down to hocklai8's answer near the bottom of the page
This comment has been migrated from the Forge. Read the original comment here.
/**
$result = (int)Db::getInstance(PS_USE_SQL_SLAVE)->getValue('
SELECT COUNT(`id_order`) AS used
FROM `'.DB_PREFIX.'orders`
WHERE `id_address_delivery` = '.(int)$this->id.'
OR `id_address_invoice` = '.(int)$this->id);
return $result > 0 ? (int)$result : false;
}
This comment has been migrated from the Forge. Read the original comment here.
The problem is that we have the possibility in the address format of the country to remove the "mandatory" fields
Required fields are: firstname, lastname,聽address1,聽city and Country:name
This is the wanted behavior
We should check when adding or editing a country if required fields are removed in the address format
If a required field is removed, we should display an error message "The %name% field is required"
Louise Bonnard peux-tu confirmer pour l'ajout de ces chaines ?
This comment has been migrated from the Forge. Read the original comment here.
Yes, alors je propose聽The %name% field is required. You can manage it here:聽%link%., c'est bon de ton c么t茅 ?
This comment has been migrated from the Forge. Read the original comment here.
Oui, nickel merci ![]()
This comment has been migrated from the Forge. Read the original comment here.
... avec les bons noms de domaines, cela donne :
The %name% field is required. You can manage it here:聽%link%.
1.7.x/Admin/Notifications/Error
Does this issue have any solution? Have the same issue and need help!
Hi @Assalea,
Sorry not yet.
There are some major issues to solve before this one.
So, it will probably not solved right now.
But PrestaShop is an open source project, so it can be solved before if someone submits a pull request to solve it.
Best regards, Khouloud
Do you know When you can have a look on it?
Hi There,
I have also the same problem is there a solution yet for the 500 error.....
@aliasali could you try this fix, and tell if it solved your issue? https://github.com/PrestaShop/PrestaShop/pull/10373
Hello @khouloudbelguith do you still reproduce this issue ?
Hi @colinegin,
Yes, I have the same issue with PS1.7.6.0.
https://drive.google.com/file/d/1v2TpEIWQezMQxVENnA069m0-oVzVejQD/view

Thanks!
@marionf , @colinegin
The issue here is that we have mandatory fields in the address table (id_country, firstname, lastname, etc...) and if we remove one of those in the address format in back office, then the form will fail at submit or even at display.
This page might be being migrated, I'll check that and inform those who are migrating the page, if the page is not being migrated I'll fix it.
Ok so I checked with @matks and I will fix it in the core, sending back an error message when we try to remove a mandatory field from the address format in back office.
Go to DB and see table required_fields, may be these field stay there, ande delete
Most helpful comment
Hi @colinegin,
Yes, I have the same issue with PS1.7.6.0.

https://drive.google.com/file/d/1v2TpEIWQezMQxVENnA069m0-oVzVejQD/view
Thanks!