Prestashop 1.7无法保存订单地址

时间:2017-02-23 10:47:23

标签: javascript php jquery prestashop prestashop-1.7

我正在尝试在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]

4 个答案:

答案 0 :(得分:1)

在Prestashop 1.7.2.2上遇到了同样的问题。

似乎在添加新地址时,它没有被持久保存到数据库中以返回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();
}

答案 1 :(得分:0)

PrestaShop地址表中的国家/地区字段是必需的,因此无法将其从地址格式中删除。

请查看商店数据库中ps_address表的结构以获取更多详细信息。

答案 2 :(得分:0)

根据上述消息,即使您已从地址格式中删除了国家/地区,系统也要求用户提供国家/地区ID。

class / Address.php 文件中,您可以清楚地看到,在列定义变量中, id_country 是必填字段,值应为正整数。< / p>

答案 3 :(得分:0)

错误提示:没有国家!简单的答案,只需在此处添加县: add country

add same country in here