Jump to content

Prestashop 1.7.4.2: Property Address->id_country is empty.


Adrian

Recommended Posts

Hi,

Well, all we have this error when we take out State:name from Country Address Format.

Is anyone that found how to resolve this ? 

To explain better: the error appear when the State:name is deleted from Locations/Country/Edit Contry/Address format and you try to add an new shipping address in your account or on checkout (when you add new shipping address). I tuck out the State:name because I have only one country activated that meant to be the default one.

The error is:

[PrestaShopException]

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

949.             }
950. 
951.             $message = $this->validateField($field, $this->$field);
952.             if ($message !== true) {
953.                 if ($die) {
954.                     throw new PrestaShopException($message);
955.                 }
956.                 return $error_return ? $message : false;
957.             }
958.         }
959. 

 

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
7 hours ago, Adrian said:

Yes. I know that ... but I don't need this field because I have only one country and this is default one.


Inside classes/Address.php

change this line:

'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),

to this:

'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),

also you can try to change to this (both should work):

'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => false),

 

After that you can hide the country and you no longer should receive that error. Please let me know if it helped!

 

If the problem persist please let me know the PS version you are using so I can help you. Regards!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...