2017-04-25 71 views
2

尝试通过web服务下订单。我已经按照通过Web服务以正确的顺序:Prestahop订单Web服务问题

  1. 创建客户(客户空白模式)
  2. 创建客户的地址(地址空白模式)
  3. 创建相关客户的购物车(手推车空白模式)
  4. 创建订单(订单空白模式)

问题是什么时候订单将被创建并保存在数据库中。我已经启动了将数据导入到客户端+地址+购物车+订单的功能; aparently一切工作正常,客户端,地址和购物车已正确创建,但不是订单...

我已经在我的本地主机上测试了php 5.6.30服务器,一切正常,但在生产php 5.5。 9服务器订单将无法创建...

这是创造秩序的功能:

$xml = $webService->get(array('url' => PS_SHOP_PATH .'api/orders/?schema=blank')); 

$pedido = $xml->children()->children(); 

$direccion = getDireccion($idCliente, $webService); 
$carrito = getCarrito($idCarrito, $webService); 

$numProdPedido = count($carrito->associations->cart_rows->cart_row); 


$pedido->id_address_delivery = $direccion['address']['id']; // Customer address 
$pedido->id_address_invoice  = $direccion['address']['id']; 
$pedido->id_cart    = $idCarrito; 
$pedido->id_currency   = $carrito->id_currency; 
$pedido->id_lang    = $carrito->id_lang; 
$pedido->mp_order_id   = $refPedido; 
$pedido->reference    = $refPedido; 
$pedido->id_customer   = $carrito->id_customer; 
$pedido->id_carrier    = $carrito->id_carrier; 
$pedido->payment    = $refPedido;//$pedido_ws['paymentType']; 
$pedido->module     = 'cashondelivery'; 
$pedido->total_paid    = $pedido_ws['total_price']; 
$pedido->total_paid_real  = $pedido_ws['total_price']; 
$pedido->total_products   = $numProdPedido; 
$pedido->total_products_wt  = $numProdPedido; 
$pedido->conversion_rate  = 1; 
// Others 
$pedido->valid      = '1'; 
$pedido->current_state    = '1'; 
getEstadoPedido($pedido->order_state); 
$pedido->total_discounts   = $pedido_ws['promotions']['total_deduced_amount']; 
$pedido->total_discounts_tax_incl = $pedido_ws['promotions']['total_deduced_amount']; 
$pedido->total_discounts_tax_excl = $pedido_ws['promotions']['total_deduced_amount']; 
$pedido->total_paid_tax_incl  = $pedido_ws['total_price']; 
$pedido->total_paid_tax_excl  = $pedido_ws['total_price']; 
$pedido->total_shipping    = $pedido_ws['shipping_price']; 
$pedido->total_shipping_tax_incl = $pedido_ws['shipping_price']; 
$pedido->total_shipping_tax_excl = $pedido_ws['shipping_price']; 
$ind = 0; 
foreach($carrito->associations->cart_rows->cart_row as $producto){ 

    $prod = getProductoById($producto->id_product, $webService); 
    $pedido->associations->order_rows->order_row[$ind]->product_id    = $producto->id_product; 
    $pedido->associations->order_rows->order_row[$ind]->product_attribute_id  = $producto->id_product_attribute; 
    $pedido->associations->order_rows->order_row[$ind]->product_quantity   = $producto->quantity; 
    $pedido->associations->order_rows->order_row[$ind]->product_name    = $prod->name->language[0]; 
    $pedido->associations->order_rows->order_row[$ind]->product_reference   = $prod->reference; 
    $pedido->associations->order_rows->order_row[$ind]->product_price    = $prod->price; 
    $pedido->associations->order_rows->order_row[$ind]->unit_price_tax_incl  = $prod->price; 
    $pedido->associations->order_rows->order_row[$ind]->unit_price_tax_excl  = $prod->price; 

    $ind++; 
} 
// Creating the order 
$opt = ['resource' => 'orders']; 
$opt['postXml'] = $xml->asXML(); 
$xml = $webService->add($opt); 

任何线索?

编辑:调用订单webservice时的XML请求和响应代码。这是最后一个订单xml。

HTTP REQUEST HEADER 
POST //api/orders HTTP/1.1 
Authorization: Basic WDMxSlRJRjFTNTNIMVlTS0hZRUFHTjlJVk5CQ1ZHTlg6 
Host: www.mywebsite.com 
Accept: */* 
Content-Length: 1956 
Content-Type: application/x-www-form-urlencoded 

HTTP RESPONSE HEADER 
HTTP/1.1 200 OK 
Server: nginx/1.4.6 (Ubuntu) 
Date: Wed, 26 Apr 2017 10:08:06 GMT 
Content-Type: text/html; charset=utf-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
Vary: Authorization,Accept-Encoding 
X-Powered-By: PHP/5.5.9-1ubuntu4.19 
Set-Cookie: PrestaShop-300d307acc0ec8525a71119b0dd393d8=0XUqFuC%2BvHy%2B%2BAU8Uod5odM7En0QQlQNh2ZWuI7VO6wTSlgh%2F%2FlVEDyz4e%2BJUv55b3N6fHTdEz%2Fmyjob65wxqjofdRVglsNIauli6yfcEBQ%3D000079; expires=Tue, 16-May-2017 10:08:05 GMT; Max-Age=1727999; path=/; domain=www.mywebsite.com; httponly 
XML SENT 
<?xml version="1.0" encoding="UTF-8"?> 
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> 
<order> 
<id/> 
<id_address_delivery>31754</id_address_delivery> 
<id_address_invoice>31754</id_address_invoice> 
<id_cart>1314430</id_cart> 
<id_currency>1</id_currency> 
<id_lang>1</id_lang> 
<id_customer>22578</id_customer> 
<id_carrier>1</id_carrier> 
<current_state>3</current_state> 
<module>cashondelivery</module> 
<invoice_number/> 
<invoice_date/> 
<delivery_number/> 
<delivery_date/> 
<valid>1</valid> 
<date_add/> 
<date_upd/> 
<shipping_number/> 
<id_shop_group/> 
<id_shop/> 
<secure_key/> 
<payment>40862744-A</payment> 
<recyclable/> 
<gift/> 
<gift_message/> 
<mobile_theme/> 
<total_discounts>0</total_discounts> 
<total_discounts_tax_incl>0</total_discounts_tax_incl> 
<total_discounts_tax_excl>0</total_discounts_tax_excl> 
<total_paid>25.98</total_paid> 
<total_paid_tax_incl>25.98</total_paid_tax_incl> 
<total_paid_tax_excl>25.98</total_paid_tax_excl> 
<total_paid_real>25.98</total_paid_real> 
<total_products>1</total_products> 
<total_products_wt>1</total_products_wt> 
<total_shipping>2.99</total_shipping> 
<total_shipping_tax_incl>2.99</total_shipping_tax_incl> 
<total_shipping_tax_excl>2.99</total_shipping_tax_excl> 
<carrier_tax_rate/> 
<total_wrapping/> 
<total_wrapping_tax_incl/> 
<total_wrapping_tax_excl/> 
<round_mode/> 
<conversion_rate>1</conversion_rate> 
<reference/> 
<associations> 
<order_rows> 
<order_row> 
<id/> 
<product_id>233154</product_id> 
<product_attribute_id>0</product_attribute_id> 
<product_quantity>1</product_quantity> 
<product_name>Smartwatch Gt08 Sim sd bluetooth Negro plata</product_name> 
<product_reference>8435338885678</product_reference> 
<product_ean13/> 
<product_upc/> 
<product_price>25.920000</product_price> 
<unit_price_tax_incl>25.920000</unit_price_tax_incl> 
<unit_price_tax_excl>25.920000</unit_price_tax_excl> 
</order_row> 
</order_rows> 
</associations> 
</order> 
</prestashop> 

返回HTTP BODY **这里是空白,不知道是否会有一些响应XML代码...

+0

这听起来像一个错字,但没有任何代码,我们真的不能帮你.. –

+0

你有一些代码@AntonisTsimourtos =) – Makros

+0

是否XML包含所有数据你期望?你有没有启用错误记录? –

回答

0

尝试这些设置为空字符串。如果这不起作用,请尝试将其设置为您的产品ID。

$xml->order->associations->order_rows->order_row[$i]->product_attribute_id 

$xml->cart->associations->cart_rows->cart_row[$i]->id_product_attribute