【问题标题】:Prestashop 1.6 Webservice OrderPrestashop 1.6 网络服务订单
【发布时间】:2018-04-16 17:32:57
【问题描述】:

我正在尝试完成我的自定义模块以从网络服务导入客户、地址、购物车和订单。

客户、地址和购物车导入工作正常,但在尝试插入新订单时,它返回此错误:

This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.

如果我查看我的 apache2 error.log 我可以看到这个错误:

 PHP Fatal error:  Call to a member function validateOrder() on boolean in /var/www/html/prestashop_pool/myshop/classes/order/Order.php on line 1463

这段代码是通过WebService添加订单的相关代码:

// Getting the structure of an order
$xml = $webService->get(array('url' => PS_SHOP_PATH .'api/orders/?schema=blank'));

    // Adding dinamic and required fields
    // Required
$xml->order->id_address_delivery    = $id_address; // Customer address
$xml->order->id_address_invoice     = $id_address;        
$xml->order->id_cart                = $id_cart; 
$xml->order->id_currency            = $id_currency;
$xml->order->id_lang                = $id_lang;
$xml->order->id_customer            = $id_customer; 
$xml->order->id_carrier             = $id_carrier;
$xml->order->module                 = $order_module;
$xml->order->payment                = $order_payment;        
$xml->order->total_paid             = $total_paid;
$xml->order->total_paid_real        = $total_paid_real;
$xml->order->total_products         = $total_products;
$xml->order->total_products_wt      = $total_products_wt;
$xml->order->conversion_rate        = 1;
// Others
$xml->order->valid                      = 1; 
$xml->order->current_state              = $id_status;        
$xml->order->total_discounts            = $total_discounts;
$xml->order->total_discounts_tax_incl   = $total_discounts_tax_incl;
$xml->order->total_discounts_tax_excl   = $total_discounts_tax_excl;
$xml->order->total_paid_tax_incl        = $total_paid_tax_incl;
$xml->order->total_paid_tax_excl        = $total_paid_tax_excl;
$xml->order->total_shipping             = $total_shipping;
$xml->order->total_shipping_tax_incl    = $total_shipping_tax_incl;
$xml->order->total_shipping_tax_excl    = $total_shipping_tax_excl;
// Order Row. Required
$xml->order->associations->order_rows->order_row[0]->product_id = $products[0]['id_product'];
$xml->order->associations->order_rows->order_row[0]->product_attribute_id   = $products[0]['id_product_attribute'];
$xml->order->associations->order_rows->order_row[0]->product_quantity       = $products[0]['quantity'];
// Order Row. Others
$xml->order->associations->order_rows->order_row[0]->product_name           = $products[0]['name'];
$xml->order->associations->order_rows->order_row[0]->product_reference      = $products[0]['reference'];
$xml->order->associations->order_rows->order_row[0]->product_price          = $products[0]['product_price'];
$xml->order->associations->order_rows->order_row[0]->unit_price_tax_incl    = $products[0]['product_price'];
$xml->order->associations->order_rows->order_row[0]->unit_price_tax_excl    = $products[0]['product_price'];

// Creating the order
$opt = array( 'resource' => 'orders' );
$opt['postXml'] = $xml->asXML();
$xml = $webService->add( $opt );
$id_order = $xml->order->id

有人知道怎么解决吗?

【问题讨论】:

  • 您使用的是正确的 $order_module 吗?你有什么版本的 prestashop 1.6?
  • 我的 $order_module 包含我要导入的自定义插件的名称(例如:'nameofplugin'),我正在使用 Prestashop 1.6.0.14。感谢您的宝贵时间。
  • 我尝试注释 $order_module 行,错误更改为 此对 PrestaShop Web 服务的调用失败并返回 HTTP 状态 400。这意味着:错误请求。
  • $order_module 的名称是必需的,并且应该与支付模块的名称相同(例如“bankwire”或“cheque”),除非您的模块是支付模块。
  • 我的模块是一个从网络服务导入订单(客户+地址+购物车+订单)的模块。如果我将 order_module 的名称设置为“cashondelivery”,它会显示第一篇文章中提到的错误。 (PHP 致命错误:在第 1463 行的 /var/www/html/prestashop_pool/myshop/classes/order/Order.php 中的布尔值上调用成员函数 validateOrder()

标签: php web-services prestashop prestashop-1.6


【解决方案1】:

这可能是由于您传入的值错误

$xml->order->module = $order_module;
$xml->order->payment = $order_payment;

检查这个值,我认为prestashop在添加模块值之前需要ps_ prefix

【讨论】:

    猜你喜欢
    • 2015-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    相关资源
    最近更新 更多