Jakub Lacko
Jakub Lacko

Reputation: 7

Prestashop 1.7 unable to save order address

i am getting this error when i am trying to save my adress in Prestashop 1.7, i've changed adress format in backend and after removing country from format i am unable to save address, can someone please help me with that ?

Image showing that error:

[PrestaShopException]

Property Address->id_country is empty
at line 915 in file classes/ObjectModel.php

910.             }
911. 
912.             $message = $this->validateField($field, $this->$field);
913.             if ($message !== true) {
914.                 if ($die) {
915.                     throw new PrestaShopException($message);
916.                 }
917.                 return $error_return ? $message : false;
918.             }
919.         }
920. 
ObjectModelCore->validateFields - [line 248 - classes/ObjectModel.php]
ObjectModelCore->getFields - [line 489 - classes/ObjectModel.php]
ObjectModelCore->add - [line 176 - classes/Address.php] - [2 Arguments]
AddressCore->add - [line 447 - classes/ObjectModel.php] - [2 Arguments]
ObjectModelCore->save - [line 76 - classes/form/CustomerAddressPersister.php]
CustomerAddressPersisterCore->save - [line 144 - 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 199 - controllers/front/OrderController.php] - [1 Arguments]
OrderControllerCore->initContent - [line 201 - classes/controller/Controller.php]
ControllerCore->run - [line 366 - classes/Dispatcher.php]
DispatcherCore->dispatch - [line 28 - index.php]

Upvotes: 0

Views: 6559

Answers (5)

Sarah Corsini
Sarah Corsini

Reputation: 1

I solved the problem by putting this setting on the country (v. image)setting

Upvotes: 0

Darius
Darius

Reputation: 268

Error say: no country! Easy answer, just add county back in here: add country

and

add same country in here

Upvotes: 0

hocklai8
hocklai8

Reputation: 31

Encountered the same issue on Prestashop 1.7.2.2.

Seems like when a new Address is added, it hasn't been persisted into the DB to return the auto-incremented id of id_address for the isUsed() function to evaluate properly.

In classes\form\CustomerAddressPersister.php

public function save(Address $address, $token)
{
    if (!$this->authorizeChange($address, $token)) {
        return false;
    }

    $address->id_customer = $this->customer->id;
    $address->save();    // <-- Add this

    if ($address->isUsed()) {
        $old_address = new Address($address->id);
        $address->id = $address->id_address = null;

        return $address->save() && $old_address->delete();
    }

    return $address->save();
}

Upvotes: 3

Dhirender
Dhirender

Reputation: 634

As per the above message, system requires country id for address from the user even you have removed country from address format.

In class/Address.php file, you can clearly see that in column definition variable, id_country is a required field as well as value should be positive integer.

Upvotes: 0

Knowband Plugins
Knowband Plugins

Reputation: 1317

The country field in the address table of PrestaShop is required, hence it is not possible to remove it from the address format.

Please check the structure of ps_address table in your store's database for more details.

Upvotes: 0

Related Questions