Prestahop订单Web服务问题

时间:2017-04-25 14:36:29

标签: php web-services prestashop-1.6

尝试通过webservice下订单。我通过webservice遵循了正确的顺序:

  1. 创建客户(客户空白架构)
  2. 创建客户地址(地址空白架构)
  3. 创建关联客户的购物车(购物车空白架构)
  4. 创建订单(订单空白架构)
  5. 问题是订单何时会被创建并保存在数据库中。我已经启动了将数据导入客户端+地址+购物车+订单的功能;显然一切正常,客户,地址和购物车是正确创建的,但不是订单......

    我已经在我的localhost圈上测试了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代码...

1 个答案:

答案 0 :(得分:0)

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

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

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