Prestashop 1.7 无法保存订单地址
Prestashop 1.7 unable to save order address
当我尝试在 Prestashop 1.7 中保存我的地址时出现此错误,我在后端更改了地址格式,从格式中删除国家/地区后我无法保存地址,有人可以帮我解决这个问题?
显示该错误的图片:
[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]
PrestaShop 地址 table 中的国家字段是必需的,因此无法将其从地址格式中删除。
请检查您商店数据库中 ps_address table 的结构以获取更多详细信息。
根据上述消息,即使您已从地址格式中删除国家/地区,系统仍需要用户提供地址的国家/地区 ID。
在class/Address.php文件中,可以清楚的看到在列定义变量中,id_country 为必填字段,且值应为正整数。
在 Prestashop 1.7.2.2 上遇到了同样的问题。
似乎在添加新地址时,它还没有保存到数据库中 return id_address 的自动递增 ID,以便 isUsed() 函数正确评估。
在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();
}
错误说:没有国家!简单的答案,只需在此处添加县:
和
我把这个设置放在国家(v. image)上解决了这个问题setting
当我尝试在 Prestashop 1.7 中保存我的地址时出现此错误,我在后端更改了地址格式,从格式中删除国家/地区后我无法保存地址,有人可以帮我解决这个问题?
显示该错误的图片:
[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]
PrestaShop 地址 table 中的国家字段是必需的,因此无法将其从地址格式中删除。
请检查您商店数据库中 ps_address table 的结构以获取更多详细信息。
根据上述消息,即使您已从地址格式中删除国家/地区,系统仍需要用户提供地址的国家/地区 ID。
在class/Address.php文件中,可以清楚的看到在列定义变量中,id_country 为必填字段,且值应为正整数。
在 Prestashop 1.7.2.2 上遇到了同样的问题。
似乎在添加新地址时,它还没有保存到数据库中 return id_address 的自动递增 ID,以便 isUsed() 函数正确评估。
在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();
}
错误说:没有国家!简单的答案,只需在此处添加县:
和
我把这个设置放在国家(v. image)上解决了这个问题setting