Prestashop 1.6 网络服务订单 [英] Prestashop 1.6 Webservice Order

查看:73
本文介绍了Prestashop 1.6 网络服务订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to finish my custom module to import clients, addresses, carts and orders from a webservice.

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

Clients, Adresses and Carts imports works fine but when trying to insert new Order, it returns this error:

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

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

If i take a look to my apache2 error.log I can see this error:

 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添加订单相关的代码:

This piece of code is the ones related to the order adittion via 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

有人知道怎么解决吗?

推荐答案

可能是你传入的值有误

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

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

check this value, I think prestashop need ps_ prefix before adding module value.

这篇关于Prestashop 1.6 网络服务订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆