Jump to content

How set a state for an order at creation time ?


lem__mel
 Share

Recommended Posts


Hi everybody.

I'm currently using the webservice API and I have a problem when creating an order: the API doesn't honor the current_state value. And I'm forced to change the state later.
The problem is that in the history the first state is visible.

Below are provided the full http messages/responses, but for the sake of the explanation I copy there some excerpts:

I send 

<id_cart>375</id_cart>
<id_currency>1</id_currency>
<id_lang>1</id_lang>
<id_customer>1</id_customer>
<id_carrier>1</id_carrier>
<current_state>5</current_state>

I receive: 

<ID><ID><![CDATA[218]]><![CDATA[21 </ID>
<ID_ADDRESS_DELIVERY xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></ID_ADDRESS_DELIVERY>
<ID_ADDRESS_INVOICE xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></ID_ADDRESS_INVOICE>
<ID_CART xlink:href="http://XXXXXXXXXXXX.fr/api/carts/375"><![CDATA[375]]></ID_CART>
<ID_CURRENCY xlink:href="http://XXXXXXXXXXXX.fr/api/currencies/1"><![CDATA[1]]></ID_CURRENCY>
<ID_LANG xlink:href="http://XXXXXXXXXXXX.fr/api/languages/1"><![CDATA[1]]></ID_LANG>
<ID_CUSTOMER xlink:href="http://XXXXXXXXXXXX.fr/api/customers/1"><![CDATA[1]]></ID_CUSTOMER>
<ID_CARRIER xlink:href="http://XXXXXXXXXXXX.fr/api/carriers/1"><![CDATA[1]]></ID_CARRIER>
<CURRENT_STATE xlink:href="http://XXXXXXXXXXXX.fr/api/order_states/"></CURRENT_STATE>

As you see the current_state 5 is not there.
When I retrieve the full order I get:

<ID><ID><![CDATA[218]]><![CDATA[218]]></ID></ID>
 <ID_ADDRESS_DELIVERY<ID_ADDRESS_DELIVERY  xlink:hrefxlink:href="http://XXXXXX.fr/api/addresses/1"><![CDATA[1]]></ID_ADDRESS_DELIVERY>
<ID_ADDRESS_INVOICE xlink:href="http://XXXXXX.fr/api/addresses/1"><![CDATA[1]]></ID_ADDRESS_INVOICE>
<ID_CART xlink:href="http://XXXXXX.fr/api/carts/375"><![CDATA[375]]></ID_CART>
<ID_CURRENCY xlink:href="http://XXXXXX.fr/api/currencies/1"><![CDATA[1]]></ID_CURRENCY>
<ID_LANG xlink:href="http://XXXXXX.fr/api/languages/1"><![CDATA[1]]></ID_LANG>
<ID_CUSTOMER xlink:href="http://XXXXXX.fr/api/customers/1"><![CDATA[1]]></ID_CUSTOMER>
<ID_CARRIER xlink:href="http://XXXXXX.fr/api/carriers/1"><![CDATA[1]]></ID_CARRIER>
<CURRENT_STATE xlink:href="http://XXXXXX.fr/api/order_states/11"><![CDATA[11]]></CURRENT_STATE>

As you see, the current_state is at the value 11


The problems are that:

  • the state 11 is a prestashop state, state that marks the order as payed, and generates an order receipt
  • I need to use a state that doesn't mark the order as payed, and so on
  • I don't want to mess with prestashop states
  • I can change the state later but in the history the previous state is visible[1]

Have someone an idea about how to force prestashop to accept at order's creation time a specific state, or to set a default arbitrary state (instead of 11) ?

 

[1] to be more precise I would like to have the order in a state of quotation, then change the price of a product in the order, and finally to mark as payed the order ; when I do this the history keep the first price as, I suppose, the order was marked as payed

P.S. : here the full Http messages

Cart creation message sent:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <cart>
        <id/>
        <id_address_delivery>1</id_address_delivery>
        <id_address_invoice>1</id_address_invoice>
        <id_currency>1</id_currency>
        <id_customer>1</id_customer>
        <id_guest/>
        <id_lang>1</id_lang>
        <id_shop_group>1</id_shop_group>
        <id_shop>1</id_shop>
        <id_carrier>1</id_carrier>
        <recyclable/>
        <gift/>
        <gift_message/>
        <mobile_theme/>
        <delivery_option/>
        <secure_key/>
        <allow_seperated_package/>
        <date_add/>
        <date_upd/>
        <associations>
            <cart_rows>
                <cart_row>
                    <id_product>330</id_product>
                    <id_product_attribute>0</id_product_attribute>
                    <id_address_delivery>1</id_address_delivery>
                    <quantity>1</quantity>
                </cart_row>
            </cart_rows>
        </associations>
    </cart>
</prestashop>

Cart creation message answer :

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<cart>
	<id><![CDATA[375]]></id>
	<id_address_delivery xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_delivery>
	<id_address_invoice xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_invoice>
	<id_currency xlink:href="http://XXXXXXXXXXXX.fr/api/currencies/1"><![CDATA[1]]></id_currency>
	<id_customer xlink:href="http://XXXXXXXXXXXX.fr/api/customers/1"><![CDATA[1]]></id_customer>
	<id_guest></id_guest>
	<id_lang xlink:href="http://XXXXXXXXXXXX.fr/api/languages/1"><![CDATA[1]]></id_lang>
	<id_shop_group><![CDATA[1]]></id_shop_group>
	<id_shop><![CDATA[1]]></id_shop>
	<id_carrier><![CDATA[1]]></id_carrier>
	<recyclable></recyclable>
	<gift></gift>
	<gift_message></gift_message>
	<mobile_theme></mobile_theme>
	<delivery_option></delivery_option>
	<secure_key></secure_key>
	<allow_seperated_package></allow_seperated_package>
	<date_add><![CDATA[2018-06-11 14:39:08]]></date_add>
	<date_upd><![CDATA[2018-06-11 14:39:08]]></date_upd>
<associations>
<cart_rows nodeType="cart_row" virtualEntity="true">
	<cart_row>
	<id_product xlink:href="http://XXXXXXXXXXXX.fr/api/products/330"><![CDATA[330]]></id_product>
	<id_product_attribute xlink:href="http://XXXXXXXXXXXX.fr/api/combinations/0"><![CDATA[0]]></id_product_attribute>
	<id_address_delivery xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_delivery>
	<quantity><![CDATA[1]]></quantity>
	</cart_row>
</cart_rows>
</associations>
</cart>
</prestashop>

Now to the order creation message:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <order>
        <id/>
        <id_address_delivery>1</id_address_delivery>
        <id_address_invoice>1</id_address_invoice>
        <id_cart>375</id_cart>
        <id_currency>1</id_currency>
        <id_lang>1</id_lang>
        <id_customer>1</id_customer>
        <id_carrier>1</id_carrier>
        <current_state>5</current_state>
        <module>XXXXX_lodgepayment</module>
        <invoice_number/>
        <invoice_date/>
        <delivery_number/>
        <delivery_date/>
        <valid/>
        <date_add/>
        <date_upd/>
        <shipping_number/>
        <id_shop_group>1</id_shop_group>
        <id_shop>1</id_shop>
        <secure_key/>
        <payment>CB - Paiement à la loge</payment>
        <recyclable/>
        <gift/>
        <gift_message/>
        <mobile_theme/>
        <total_discounts/>
        <total_discounts_tax_incl/>
        <total_discounts_tax_excl/>
        <total_paid>3.5</total_paid>
        <total_paid_tax_incl/>
        <total_paid_tax_excl/>
        <total_paid_real>3.5</total_paid_real>
        <total_products>2.92</total_products>
        <total_products_wt>3.5</total_products_wt>
        <total_shipping/>
        <total_shipping_tax_incl/>
        <total_shipping_tax_excl/>
        <carrier_tax_rate/>
        <total_wrapping/>
        <total_wrapping_tax_incl/>
        <total_wrapping_tax_excl/>
        <round_mode/>
        <round_type/>
        <conversion_rate>1</conversion_rate>
        <reference/>
        <associations>
            <order_rows>
                <order_row>
                    <id/>
                    <product_id>330</product_id>
                    <product_attribute_id>0</product_attribute_id>
                    <product_quantity>1</product_quantity>
                    <product_name/>
                    <product_reference/>
                    <product_ean13/>
                    <product_isbn/>
                    <product_upc/>
                    <product_price/>
                    <unit_price_tax_incl/>
                    <unit_price_tax_excl/>
                </order_row>
            </order_rows>
        </associations>
    </order>
</prestashop>

and the server response:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id><![CDATA[218]]></id>
	<id_address_delivery xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_delivery>
	<id_address_invoice xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_invoice>
	<id_cart xlink:href="http://XXXXXXXXXXXX.fr/api/carts/375"><![CDATA[375]]></id_cart>
	<id_currency xlink:href="http://XXXXXXXXXXXX.fr/api/currencies/1"><![CDATA[1]]></id_currency>
	<id_lang xlink:href="http://XXXXXXXXXXXX.fr/api/languages/1"><![CDATA[1]]></id_lang>
	<id_customer xlink:href="http://XXXXXXXXXXXX.fr/api/customers/1"><![CDATA[1]]></id_customer>
	<id_carrier xlink:href="http://XXXXXXXXXXXX.fr/api/carriers/1"><![CDATA[1]]></id_carrier>
	<current_state xlink:href="http://XXXXXXXXXXXX.fr/api/order_states/"></current_state>
	<module><![CDATA[triethic_lodgepayment]]></module>
	<invoice_number></invoice_number>
	<invoice_date></invoice_date>
	<delivery_number></delivery_number>
	<delivery_date></delivery_date>
	<valid></valid>
	<date_add></date_add>
	<date_upd></date_upd>
	<shipping_number notFilterable="true"></shipping_number>
	<id_shop_group><![CDATA[1]]></id_shop_group>
	<id_shop><![CDATA[1]]></id_shop>
	<secure_key></secure_key>
	<payment><![CDATA[CB - Paiement à la loge]]></payment>
	<recyclable></recyclable>
	<gift></gift>
	<gift_message></gift_message>
	<mobile_theme></mobile_theme>
	<total_discounts></total_discounts>
	<total_discounts_tax_incl></total_discounts_tax_incl>
	<total_discounts_tax_excl></total_discounts_tax_excl>
	<total_paid><![CDATA[3.5]]></total_paid>
	<total_paid_tax_incl></total_paid_tax_incl>
	<total_paid_tax_excl></total_paid_tax_excl>
	<total_paid_real><![CDATA[3.5]]></total_paid_real>
	<total_products><![CDATA[2.92]]></total_products>
	<total_products_wt><![CDATA[3.5]]></total_products_wt>
	<total_shipping></total_shipping>
	<total_shipping_tax_incl></total_shipping_tax_incl>
	<total_shipping_tax_excl></total_shipping_tax_excl>
	<carrier_tax_rate></carrier_tax_rate>
	<total_wrapping></total_wrapping>
	<total_wrapping_tax_incl></total_wrapping_tax_incl>
	<total_wrapping_tax_excl></total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate><![CDATA[1]]></conversion_rate>
	<reference></reference>
<associations>
<order_rows nodeType="order_row" virtualEntity="true">
	<order_row>
	<id><![CDATA[304]]></id>
	<product_id><![CDATA[330]]></product_id>
	<product_attribute_id><![CDATA[0]]></product_attribute_id>
	<product_quantity><![CDATA[1]]></product_quantity>
	<product_name><![CDATA[Repassage | Jogging]]></product_name>
	<product_reference><![CDATA[BSREP0289]]></product_reference>
	<product_ean13></product_ean13>
	<product_isbn></product_isbn>
	<product_upc></product_upc>
	<product_price><![CDATA[2.916667]]></product_price>
	<unit_price_tax_incl><![CDATA[3.500000]]></unit_price_tax_incl>
	<unit_price_tax_excl><![CDATA[2.916667]]></unit_price_tax_excl>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>

 

And when you check the full order (through a call to http://XXXXXXXXXXXX.fr/api/orders/218) :

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id><![CDATA[218]]></id>
	<id_address_delivery xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_delivery>
	<id_address_invoice xlink:href="http://XXXXXXXXXXXX.fr/api/addresses/1"><![CDATA[1]]></id_address_invoice>
	<id_cart xlink:href="http://XXXXXXXXXXXX.fr/api/carts/375"><![CDATA[375]]></id_cart>
	<id_currency xlink:href="http://XXXXXXXXXXXX.fr/api/currencies/1"><![CDATA[1]]></id_currency>
	<id_lang xlink:href="http://XXXXXXXXXXXX.fr/api/languages/1"><![CDATA[1]]></id_lang>
	<id_customer xlink:href="http://XXXXXXXXXXXX.fr/api/customers/1"><![CDATA[1]]></id_customer>
	<id_carrier xlink:href="http://XXXXXXXXXXXX.fr/api/carriers/1"><![CDATA[1]]></id_carrier>
	<current_state xlink:href="http://XXXXXXXXXXXX.fr/api/order_states/11"><![CDATA[11]]></current_state>
	<module><![CDATA[triethic_lodgepayment]]></module>
	<invoice_number><![CDATA[203]]></invoice_number>
	<invoice_date><![CDATA[2018-06-11 14:40:37]]></invoice_date>
	<delivery_number><![CDATA[0]]></delivery_number>
	<delivery_date><![CDATA[0000-00-00 00:00:00]]></delivery_date>
	<valid><![CDATA[1]]></valid>
	<date_add><![CDATA[2018-06-11 14:40:36]]></date_add>
	<date_upd><![CDATA[2018-06-11 14:40:37]]></date_upd>
	<shipping_number notFilterable="true"></shipping_number>
	<id_shop_group><![CDATA[1]]></id_shop_group>
	<id_shop><![CDATA[1]]></id_shop>
	<secure_key><![CDATA[3ebfc2cd81af35637a9baffa10eaca19]]></secure_key>
	<payment><![CDATA[CB - Paiement à la loge]]></payment>
	<recyclable><![CDATA[0]]></recyclable>
	<gift><![CDATA[0]]></gift>
	<gift_message></gift_message>
	<mobile_theme><![CDATA[0]]></mobile_theme>
	<total_discounts><![CDATA[0.000000]]></total_discounts>
	<total_discounts_tax_incl><![CDATA[0.000000]]></total_discounts_tax_incl>
	<total_discounts_tax_excl><![CDATA[0.000000]]></total_discounts_tax_excl>
	<total_paid><![CDATA[3.500000]]></total_paid>
	<total_paid_tax_incl><![CDATA[3.500000]]></total_paid_tax_incl>
	<total_paid_tax_excl><![CDATA[2.920000]]></total_paid_tax_excl>
	<total_paid_real><![CDATA[3.500000]]></total_paid_real>
	<total_products><![CDATA[2.920000]]></total_products>
	<total_products_wt><![CDATA[3.500000]]></total_products_wt>
	<total_shipping><![CDATA[0.000000]]></total_shipping>
	<total_shipping_tax_incl><![CDATA[0.000000]]></total_shipping_tax_incl>
	<total_shipping_tax_excl><![CDATA[0.000000]]></total_shipping_tax_excl>
	<carrier_tax_rate><![CDATA[20.000]]></carrier_tax_rate>
	<total_wrapping><![CDATA[0.000000]]></total_wrapping>
	<total_wrapping_tax_incl><![CDATA[0.000000]]></total_wrapping_tax_incl>
	<total_wrapping_tax_excl><![CDATA[0.000000]]></total_wrapping_tax_excl>
	<round_mode><![CDATA[2]]></round_mode>
	<round_type><![CDATA[2]]></round_type>
	<conversion_rate><![CDATA[1.000000]]></conversion_rate>
	<reference><![CDATA[MBUHDONBV]]></reference>
<associations>
<order_rows nodeType="order_row" virtualEntity="true">
	<order_row>
	<id><![CDATA[304]]></id>
	<product_id><![CDATA[330]]></product_id>
	<product_attribute_id><![CDATA[0]]></product_attribute_id>
	<product_quantity><![CDATA[1]]></product_quantity>
	<product_name><![CDATA[Repassage | Jogging]]></product_name>
	<product_reference><![CDATA[BSREP0289]]></product_reference>
	<product_ean13></product_ean13>
	<product_isbn></product_isbn>
	<product_upc></product_upc>
	<product_price><![CDATA[2.916667]]></product_price>
	<unit_price_tax_incl><![CDATA[3.500000]]></unit_price_tax_incl>
	<unit_price_tax_excl><![CDATA[2.916667]]></unit_price_tax_excl>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>

 

Edited by lem__mel
anonymising (see edit history)

Share this post


Link to post
Share on other sites

I created a ticket in prestashop's forge: BOOM-5732
Well as it was predictable, there is no answer at this time, and more there is no problem (not reproductible), even though I provided VM and videos, and precise instructions.

And as I will probably not have any more answer, and for the potential reader, if you don't want to alter prestashop's code (or create a prestashop's module), you will have to (instead of one simple operation: POST an order), you will have to:

  • POST the order
  • GET the order
  • GET order_histories
  • DELETE the order_history associated
  • PUT the order updated

 

But be carefull! If you wanted to set a current_state that doesn't generate invoice, you will have more work to do; I will not show how to do it as I don't have to do it: for this point, see the API order_payments.

In the following "instructions", you will have to replace MY_SECRET_KEY with your webservice key, and MY_URL with your server URL. And at last, in the following instructions:

  • I use curl for simple test/proof
  • I use my very own products, so you will have to check/change the product's id
  • the curl command was used on a linux-bash shell, so I don't know what is required to protect (if required) the strings on Windows

 

First you create a cart with this:

curl -X POST -i 'http://MY_SECRET_KEY:@MY_URL/api/carts' --data '<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <cart>
        <id/>
        <id_address_delivery>1</id_address_delivery>
        <id_address_invoice>1</id_address_invoice>
        <id_currency>1</id_currency>
        <id_customer>1</id_customer>
        <id_guest/>
        <id_lang>1</id_lang>
        <id_shop_group>1</id_shop_group>
        <id_shop>1</id_shop>
        <id_carrier>1</id_carrier>
        <recyclable/>
        <gift/>
        <gift_message/>
        <mobile_theme/>
        <delivery_option/>
        <secure_key/>
        <allow_seperated_package/>
        <date_add/>
        <date_upd/>
        <associations>
            <cart_rows>
                <cart_row>
                    <id_product>329</id_product>
                    <id_product_attribute>0</id_product_attribute>
                    <id_address_delivery>1</id_address_delivery>
                    <quantity>1</quantity>
                </cart_row>
            </cart_rows>
        </associations>
    </cart>
</prestashop>'

Then post something like this for the order creation (take care of the id_cart):

curl -X POST -i 'http://MY_SECRET_KEY:@MY_URL/api/orders' --data '<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <order>
        <id/>
        <id_address_delivery>1</id_address_delivery>
        <id_address_invoice>1</id_address_invoice>
        <id_cart>381</id_cart>
        <id_currency>1</id_currency>
        <id_lang>1</id_lang>
        <id_customer>1</id_customer>
        <id_carrier>1</id_carrier>
        <current_state>5</current_state>
        <module>ps_checkpayment</module>
        <invoice_number/>
        <invoice_date/>
        <delivery_number/>
        <delivery_date/>
        <valid>0</valid>
        <date_add/>
        <date_upd/>
        <shipping_number/>
        <id_shop_group>1</id_shop_group>
        <id_shop>1</id_shop>
        <secure_key/>
        <payment>Chèque</payment>
        <recyclable/>
        <gift/>
        <gift_message/>
        <mobile_theme/>
        <total_discounts/>
        <total_discounts_tax_incl/>
        <total_discounts_tax_excl/>
        <total_paid>2.200000</total_paid>
        <total_paid_tax_incl/>
        <total_paid_tax_excl/>
        <total_paid_real>2.200000</total_paid_real>
        <total_products>1.830000</total_products>
        <total_products_wt>2.200000</total_products_wt>
        <total_shipping/>
        <total_shipping_tax_incl/>
        <total_shipping_tax_excl/>
        <carrier_tax_rate/>
        <total_wrapping/>
        <total_wrapping_tax_incl/>
        <total_wrapping_tax_excl/>
        <round_mode/>
        <round_type/>
        <conversion_rate>1</conversion_rate>
        <reference/>
        <associations>
            <order_rows>
                <order_row>
                    <id/>
                    <product_id>329</product_id>
                    <product_attribute_id>0</product_attribute_id>
                    <product_quantity>1</product_quantity>
                    <product_name/>
                    <product_reference/>
                    <product_ean13/>
                    <product_isbn/>
                    <product_upc/>
                    <product_price/>
                    <unit_price_tax_incl/>
                    <unit_price_tax_excl/>
                </order_row>
            </order_rows>
        </associations>
    </order>
</prestashop>'

Now the additional work:

  • look for the associated history record (with the id_order retrieve from the last POST):
    http://MY_URL/api/order_histories?display=full&filter[id_order]=223
  • delete the associated order_history; in my case 339
    curl -X DELETE -i 'http://MY_SECRET_KEY:@MY_URL/api/order_histories/339'
  • retrieve the full order (take care of the id_cart): 
    http://MY_URL/api/orders/223
  • update your order (with a new current_state):
    curl -X PUT -i 'http://MY_SECRET_KEY:@MY_URL/api/orders/223' --data '<?xml version="1.0" encoding="UTF-8"?>
    <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
        <order>
            <id><![CDATA[223]]></id>
            <id_address_delivery xlink:href="http://MY_URL/api/addresses/1"><![CDATA[1]]></id_address_delivery>
            <id_address_invoice xlink:href="http://MY_URL/api/addresses/1"><![CDATA[1]]></id_address_invoice>
            <id_cart xlink:href="http://MY_URL/api/carts/381"><![CDATA[381]]></id_cart>
            <id_currency xlink:href="http://MY_URL/api/currencies/1"><![CDATA[1]]></id_currency>
            <id_lang xlink:href="http://MY_URL/api/languages/1"><![CDATA[1]]></id_lang>
            <id_customer xlink:href="http://MY_URL/api/customers/1"><![CDATA[1]]></id_customer>
            <id_carrier xlink:href="http://MY_URL/api/carriers/1"><![CDATA[1]]></id_carrier>
            <current_state xlink:href="http://MY_URL/api/order_states/5"><![CDATA[5]]></current_state>
            <module><![CDATA[ps_checkpayment]]></module>
            <invoice_number><![CDATA[207]]></invoice_number>
            <invoice_date><![CDATA[2018-06-18 13:52:09]]></invoice_date>
            <delivery_number><![CDATA[0]]></delivery_number>
            <delivery_date><![CDATA[0000-00-00 00:00:00]]></delivery_date>
            <valid><![CDATA[1]]></valid>
            <date_add><![CDATA[2018-06-18 13:52:08]]></date_add>
            <date_upd><![CDATA[2018-06-18 13:52:09]]></date_upd>
            <shipping_number notFilterable="true"></shipping_number>
            <id_shop_group><![CDATA[1]]></id_shop_group>
            <id_shop><![CDATA[1]]></id_shop>
            <secure_key><![CDATA[3ebfc2cd81af35637a9baffa10eaca19]]></secure_key>
            <payment><![CDATA[Chèque]]></payment>
            <recyclable><![CDATA[0]]></recyclable>
            <gift><![CDATA[0]]></gift>
            <gift_message></gift_message>
            <mobile_theme><![CDATA[0]]></mobile_theme>
            <total_discounts><![CDATA[0.000000]]></total_discounts>
            <total_discounts_tax_incl><![CDATA[0.000000]]></total_discounts_tax_incl>
            <total_discounts_tax_excl><![CDATA[0.000000]]></total_discounts_tax_excl>
            <total_paid><![CDATA[2.200000]]></total_paid>
            <total_paid_tax_incl><![CDATA[2.200000]]></total_paid_tax_incl>
            <total_paid_tax_excl><![CDATA[1.830000]]></total_paid_tax_excl>
            <total_paid_real><![CDATA[2.200000]]></total_paid_real>
            <total_products><![CDATA[1.830000]]></total_products>
            <total_products_wt><![CDATA[2.200000]]></total_products_wt>
            <total_shipping><![CDATA[0.000000]]></total_shipping>
            <total_shipping_tax_incl><![CDATA[0.000000]]></total_shipping_tax_incl>
            <total_shipping_tax_excl><![CDATA[0.000000]]></total_shipping_tax_excl>
            <carrier_tax_rate><![CDATA[20.000]]></carrier_tax_rate>
            <total_wrapping><![CDATA[0.000000]]></total_wrapping>
            <total_wrapping_tax_incl><![CDATA[0.000000]]></total_wrapping_tax_incl>
            <total_wrapping_tax_excl><![CDATA[0.000000]]></total_wrapping_tax_excl>
            <round_mode><![CDATA[2]]></round_mode>
            <round_type><![CDATA[2]]></round_type>
            <conversion_rate><![CDATA[1.000000]]></conversion_rate>
            <reference><![CDATA[ACYLRUQTX]]></reference>
            <associations>
                <order_rows nodeType="order_row" virtualEntity="true">
                    <order_row>
                        <id><![CDATA[309]]></id>
                        <product_id><![CDATA[329]]></product_id>
                        <product_attribute_id><![CDATA[0]]></product_attribute_id>
                        <product_quantity><![CDATA[1]]></product_quantity>
                        <product_name><![CDATA[Repassage | Chemise pliée]]></product_name>
                        <product_reference><![CDATA[BSREP028]]></product_reference>
                        <product_ean13></product_ean13>
                        <product_isbn></product_isbn>
                        <product_upc></product_upc>
                        <product_price><![CDATA[1.833333]]></product_price>
                        <unit_price_tax_incl><![CDATA[2.200000]]></unit_price_tax_incl>
                        <unit_price_tax_excl><![CDATA[1.833333]]></unit_price_tax_excl>
                    </order_row>
                </order_rows>
            </associations>
        </order>
    </prestashop>'

     

 

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi,

The current_state field from webservice has PS_OS_WS_PAYMENT as default value. To change it I had to override the Order Class. In the second parameter of the function validateOrder you specify the current_state value.

    public function addWs($autodate = true, $null_values = false)
    {
        /** @var PaymentModule $payment_module */
        $payment_module = Module::getInstanceByName($this->module);
        $customer = new Customer($this->id_customer);
        if($this->module=="cashondelivery")        
            $payment_module->validateOrder($this->id_cart, Configuration::get('PS_OS_PREPARATION'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);
        elseif($this->module=="bankwire")        
            $payment_module->validateOrder($this->id_cart, Configuration::get('PS_OS_BANKWIRE'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);
        else
            $payment_module->validateOrder($this->id_cart, Configuration::get('PS_OS_WS_PAYMENT'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);
        $this->id = $payment_module->currentOrder;
        return true;
    }


 

Hope it helps!

  • Thanks 1

Share this post


Link to post
Share on other sites

  • 11 months later...
  • 3 years later...

Hi,

Two years later need a solution to this as well. Am otherwise successfully able to create a new order via Webservice in Prestashop 1.7.8.2, but the state is wrong.

The initial value for "current_state" is "payment error", which is totally incorrect even though I give a valid state ID to the order before posting.

It would really not matter that much, but the customer will receive an e-mail about the initial state before I can update it by saving a new state via order_history.

Is there no reasonable way to give a new order a desired state when creating ig using Webservice?

Thanks!

Best regards,

Tauno

 

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More