doucheng2053
2017-02-23 10:47
浏览 56

Prestashop 1.7无法保存订单地址

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]

图片转代码服务由CSDN问答提供 功能建议

当我试图在Prestashop 1.7中保存我的地址时,我收到此错误,我改变了地址格式 后端和从格式中删除国家后我无法保存地址,有人可以帮我吗?

显示错误的图片:

< img src =“https://i.stack.imgur.com/Y3HJQ.png”alt =“”>

  [PrestaShopException] 
 
Property Address-&gt;  id_country在文件类/ ObjectModel.php 
 
910中为空
at行915。  } 
911。  
912。  $ message = $ this-&gt; validateField($ field,$ this-&gt; $ field); 
913。  if($ message!== true){
914。  if($ die){
915。 抛出新的PrestaShopException($ message); 
916。  } \ N917。 返回$ error_return?  $ message:false; 
918。  } 
919。  } \ N920。  
ObjectModelCore-&gt; validateFields  -  [第248行 -  classes / ObjectModel.php] 
ObjectModelCore-&gt; getFields  -  [第489行 -  classes / ObjectModel.php] 
ObjectModelCore-&gt; add  -  [第176行 -  classes / Address.php  ]  -  [2 Arguments] 
AddressCore-&gt; add  -  [line 447  -  classes / ObjectModel.php]  -  [2 Arguments] 
ObjectModelCore-&gt; save  -  [line 76  -  classes / form / CustomerAddressPersister.php] 
CustomerAddressPersisterCore-  &gt;保存 -  [第144行 -  classes / form / CustomerAddressForm.php]  -  [2 Arguments] 
CustomerAddressFormCore-&gt; submit  -  [第111行 -  classes / checkout / CheckoutAddressesStep.php] 
CheckoutAddressesStepCore-&gt; handleRequest  -  [第57行  -  classes / checkout / CheckoutProcess.php]  -  [1 Arguments] 
CheckoutProcessCore-&gt; handleRequest  -  [line 199  -  controllers / front / OrderController.php]  -  [1 Arguments] 
OrderControllerCore-&gt; initContent  -  [line 201  -  classes  /controller/Controller.php]
ControllerCore->run  -  [第366行 -  classes / Dispatcher.php] 
DispatcherCore-&gt; dispatch  -  [第28行 -  index.php  ] 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dousong1926 2017-02-24 11:42
    已采纳

    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.

    打赏 评论
  • duanlu1908 2017-02-24 12:22

    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.

    打赏 评论
  • drh47606 2017-10-23 16:52

    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();
    }
    
    打赏 评论
  • dongyipa0028 2019-01-25 08:07

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

    and

    add same country in here

    打赏 评论

相关推荐 更多相似问题