Jump to content

Create an order from the webservice api


Recommended Posts

Hi !

I want to create an order on my shops with the API, so at first I create a card with the following call :

POST mypresta.com/api/carts?ws_key=my_key

body:

<?xml version="1.0" encoding="UTF-8"?>
    <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
        <cart>
            <id_currency><![CDATA[1]]></id_currency>
            <id_lang><![CDATA[1]]></id_lang>
            <associations>
                <cart_rows nodeType="cart_row" virtualEntity="true">
                    <order_row>
                      <id_product><![CDATA[1]]></id_product>
                      <id_product_attribute><![CDATA[1]]></id_product_attribute>
                      <quantity><![CDATA[5]]></quantity>
                      <id_address_delivery><![CDATA[1]]></id_address_delivery>
                    </order_row>
                    <order_row>
                      <id_product><![CDATA[2]]></id_product>
                      <id_product_attribute><![CDATA[2]]></id_product_attribute>
                      <quantity><![CDATA[4]]></quantity>
                      <id_address_delivery><![CDATA[1]]></id_address_delivery>
                    </order_row>
                </cart_rows>
            </associations>
        </cart>
    </prestashop>

and then, with the generated card, i want to create my order with a second call :

POST mypresta.com/api/orders?ws_key=my_key

body:

<?xml version="1.0" encoding="UTF-8"?>
    <prestashop>
        <order>
            <id_address_delivery><![CDATA[1]]></id_address_delivery>
            <id_address_invoice><![CDATA[1]]></id_address_invoice>
            <id_cart><![CDATA[9]]></id_cart>
            <id_currency><![CDATA[1]]></id_currency>
            <id_lang><![CDATA[1]]></id_lang>
            <id_customer><![CDATA[1]]></id_customer>
            <id_carrier><![CDATA[2]]></id_carrier>
            <current_state><![CDATA[2]]></current_state>
            <module><![CDATA[cheque]]></module>
            <payment><![CDATA[Payment by check]]></payment>
            <total_paid><![CDATA[45]]></total_paid>
            <total_paid_real><![CDATA[45]]></total_paid_real>
            <total_products><![CDATA[2]]></total_products>
            <total_products_wt><![CDATA[2]]></total_products_wt>
            <conversion_rate><![CDATA[1]]></conversion_rate>
            <associations>
                <order_rows nodeType="order_row" virtualEntity="true">
                    <order_row>
                      <product_id><![CDATA[1]]></product_id>
                      <product_attribute_id><![CDATA[1]]></product_attribute_id>
                      <product_quantity><![CDATA[5]]></product_quantity>
                    </order_row>
                    <order_row>
                      <product_id><![CDATA[2]]></product_id>
                      <product_attribute_id><![CDATA[2]]></product_attribute_id>
                      <product_quantity><![CDATA[4]]></product_quantity>
                    </order_row>
                </order_rows>
            </associations>
        </order>
    </prestashop>

on this second call i got a response with the http code 200 and the following raw text: FATAL ERROR

How can i create order on my shops from the webservices ?

 

PS: presta version 1.5 or 1.6 or 1.7 (got the same error on all those versions)

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...