Jump to content

Edit History

pppplus

pppplus

Bonjour à tous !

Je suis en train d'essayer d'améliorer mes scripts webservice pour mes commandes extérieures, et je galère sur quelques points.

Je vous en soumets un aujourd'hui.

J'essaie de passer une commande d'un produit avec une déclinaison.
Malheureusement, je n'y arrive pas, ça commande le produit, sans aucune déclinaison choisie.
C'est d'ailleurs étrange, car ça diminue le stock du produit en tant que tel, mais ne diminue aucune déclinaison.

Pour info, je prends le product_attribute_id dans la table ps_product_attribute

Partie PHP qui génère le XML :

                $xml->children()->children()->associations->addChild('order_rows');
                //on insert une ligne cart_row par produit
                foreach($myOrder['order_rows'] as $newP) {
                    $xml->children()->children()->associations->order_rows->addChild('order_row');
                    $xml->children()->children()->associations->order_rows->order_row->addChild('id_product', $newP['id_product']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_attribute_id', $newP['product_attribute_id']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('quantity', $newP['quantity']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_name', $newP['product_name']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_reference', $newP['product_reference']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_ean13', $newP['product_ean13']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_upc', $newP['product_upc']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_price', $newP['product_price']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_incl', $newP['unit_price_tax_incl']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_excl', $newP['unit_price_tax_excl']);
                }

 

Ensuite, ça me sort bien le XML voulu :
 

Array
(
    [resource] => orders
    [postXml] => <!--?xml version="1.0" encoding="UTF-8"?-->
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>48</id_address_delivery>
	<id_address_invoice>48</id_address_invoice>
	<id_cart>49</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>45</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-620378</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13><product_upc><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></product_upc></product_ean13></order_row></order_rows></associations>
</order>
</prestashop>

)

 

Sauf qu'après envoie de
$xml = $webService->add( $opt );
L'id de l'attribut n'est pas pris en compte.

Le debug webservice me renvoie :

XML SENT

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>49</id_address_delivery>
	<id_address_invoice>49</id_address_invoice>
	<id_cart>50</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>46</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-305342</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13/><product_upc/><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></order_row></order_rows></associations>
</order>
</prestashop>

RETURN HTTP BODY

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id><![CDATA[46]]></id>
	<id_address_delivery xlink:href="http://test1751.coque-personnalisable.com/api/addresses/49"><![CDATA[49]]></id_address_delivery>
	<id_address_invoice xlink:href="http://test1751.coque-personnalisable.com/api/addresses/49"><![CDATA[49]]></id_address_invoice>
	<id_cart xlink:href="http://test1751.coque-personnalisable.com/api/carts/50"><![CDATA[50]]></id_cart>
	<id_currency xlink:href="http://test1751.coque-personnalisable.com/api/currencies/1"><![CDATA[1]]></id_currency>
	<id_lang xlink:href="http://test1751.coque-personnalisable.com/api/languages/1"><![CDATA[1]]></id_lang>
	<id_customer xlink:href="http://test1751.coque-personnalisable.com/api/customers/46"><![CDATA[46]]></id_customer>
	<id_carrier xlink:href="http://test1751.coque-personnalisable.com/api/carriers/3"><![CDATA[3]]></id_carrier>
	<current_state xlink:href="http://test1751.coque-personnalisable.com/api/order_states/"></current_state>
	<module><![CDATA[ps_wirepayment]]></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[zonzon test1-305342]]></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[10.99]]></total_paid>
	<total_paid_tax_incl><![CDATA[10.99]]></total_paid_tax_incl>
	<total_paid_tax_excl><![CDATA[10.99]]></total_paid_tax_excl>
	<total_paid_real><![CDATA[10.99]]></total_paid_real>
	<total_products><![CDATA[9.7]]></total_products>
	<total_products_wt><![CDATA[9.7]]></total_products_wt>
	<total_shipping><![CDATA[4.49]]></total_shipping>
	<total_shipping_tax_incl><![CDATA[4.49]]></total_shipping_tax_incl>
	<total_shipping_tax_excl><![CDATA[4.49]]></total_shipping_tax_excl>
	<carrier_tax_rate><![CDATA[0]]></carrier_tax_rate>
	<total_wrapping><![CDATA[0]]></total_wrapping>
	<total_wrapping_tax_incl><![CDATA[0]]></total_wrapping_tax_incl>
	<total_wrapping_tax_excl><![CDATA[0]]></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[48]]></id>
	<product_id><![CDATA[17]]></product_id>
	<product_attribute_id><![CDATA[0]]></product_attribute_id>
	<product_quantity><![CDATA[1]]></product_quantity>
	<product_name><![CDATA[Carnet de notes Ours brun]]></product_name>
	<product_reference><![CDATA[demo_9]]></product_reference>
	<product_ean13></product_ean13>
	<product_isbn></product_isbn>
	<product_upc></product_upc>
	<product_price><![CDATA[12.900000]]></product_price>
	<unit_price_tax_incl><![CDATA[15.480000]]></unit_price_tax_incl>
	<unit_price_tax_excl><![CDATA[12.900000]]></unit_price_tax_excl>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>

 

Voilà, vers la fin, plus d'id attribut :

    < product_id ><![CDATA[17]]>< /product_id >
    < product_attribute_id ><![CDATA[0]]>< /product_attribute_id >

 

Je sèche, je n'ai plus d'idée, et je ne trouve pas grand chose sur les webservices sur gogole...
Merci d'avance pour votre aide !

pppplus

pppplus

Bonjour à tous !

Je suis en train d'essayer d'améliorer mes scripts webservice pour mes commandes extérieures, et je galère sur quelques points.

Je vous en soumets un aujourd'hui.

J'essaie de passer une commande d'un produit avec une déclinaison.
Malheureusement, je n'y arrive pas, ça commande le produit, sans aucune déclinaison choisie.
C'est d'ailleurs étrange, car ça diminue le stock du produit en tant que tel, mais ne diminue aucune déclinaison.

Pour info, je prends le product_attribute_id dans la table ps_product_attribute

Partie PHP qui génère le XML :

                $xml->children()->children()->associations->addChild('order_rows');
                //on insert une ligne cart_row par produit
                foreach($myOrder['order_rows'] as $newP) {
                    $xml->children()->children()->associations->order_rows->addChild('order_row');
                    $xml->children()->children()->associations->order_rows->order_row->addChild('id_product', $newP['id_product']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_attribute_id', $newP['product_attribute_id']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('quantity', $newP['quantity']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_name', $newP['product_name']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_reference', $newP['product_reference']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_ean13', $newP['product_ean13']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_upc', $newP['product_upc']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_price', $newP['product_price']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_incl', $newP['unit_price_tax_incl']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_excl', $newP['unit_price_tax_excl']);
                }

 

Ensuite, ça me sort bien le XML voulu :
 

Array
(
    [resource] => orders
    [postXml] => <!--?xml version="1.0" encoding="UTF-8"?-->
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>48</id_address_delivery>
	<id_address_invoice>48</id_address_invoice>
	<id_cart>49</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>45</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-620378</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13><product_upc><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></product_upc></product_ean13></order_row></order_rows></associations>
</order>
</prestashop>

)

 

Sauf qu'après envoie de
$xml = $webService->add( $opt );
L'id de l'attribut n'est pas pris en compte.

Le debug webservice me renvoie :

XML SENT

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>49</id_address_delivery>
	<id_address_invoice>49</id_address_invoice>
	<id_cart>50</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>46</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-305342</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13/><product_upc/><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></order_row></order_rows></associations>
</order>
</prestashop>

RETURN HTTP BODY

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id><![CDATA[46]]></id>
	<id_address_delivery xlink:href="http://test1751.coque-personnalisable.com/api/addresses/49"><![CDATA[49]]></id_address_delivery>
	<id_address_invoice xlink:href="http://test1751.coque-personnalisable.com/api/addresses/49"><![CDATA[49]]></id_address_invoice>
	<id_cart xlink:href="http://test1751.coque-personnalisable.com/api/carts/50"><![CDATA[50]]></id_cart>
	<id_currency xlink:href="http://test1751.coque-personnalisable.com/api/currencies/1"><![CDATA[1]]></id_currency>
	<id_lang xlink:href="http://test1751.coque-personnalisable.com/api/languages/1"><![CDATA[1]]></id_lang>
	<id_customer xlink:href="http://test1751.coque-personnalisable.com/api/customers/46"><![CDATA[46]]></id_customer>
	<id_carrier xlink:href="http://test1751.coque-personnalisable.com/api/carriers/3"><![CDATA[3]]></id_carrier>
	<current_state xlink:href="http://test1751.coque-personnalisable.com/api/order_states/"></current_state>
	<module><![CDATA[ps_wirepayment]]></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[zonzon test1-305342]]></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[10.99]]></total_paid>
	<total_paid_tax_incl><![CDATA[10.99]]></total_paid_tax_incl>
	<total_paid_tax_excl><![CDATA[10.99]]></total_paid_tax_excl>
	<total_paid_real><![CDATA[10.99]]></total_paid_real>
	<total_products><![CDATA[9.7]]></total_products>
	<total_products_wt><![CDATA[9.7]]></total_products_wt>
	<total_shipping><![CDATA[4.49]]></total_shipping>
	<total_shipping_tax_incl><![CDATA[4.49]]></total_shipping_tax_incl>
	<total_shipping_tax_excl><![CDATA[4.49]]></total_shipping_tax_excl>
	<carrier_tax_rate><![CDATA[0]]></carrier_tax_rate>
	<total_wrapping><![CDATA[0]]></total_wrapping>
	<total_wrapping_tax_incl><![CDATA[0]]></total_wrapping_tax_incl>
	<total_wrapping_tax_excl><![CDATA[0]]></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[48]]></id>
	<product_id><![CDATA[17]]></product_id>
	<product_attribute_id><![CDATA[0]]></product_attribute_id>
	<product_quantity><![CDATA[1]]></product_quantity>
	<product_name><![CDATA[Carnet de notes Ours brun]]></product_name>
	<product_reference><![CDATA[demo_9]]></product_reference>
	<product_ean13></product_ean13>
	<product_isbn></product_isbn>
	<product_upc></product_upc>
	<product_price><![CDATA[12.900000]]></product_price>
	<unit_price_tax_incl><![CDATA[15.480000]]></unit_price_tax_incl>
	<unit_price_tax_excl><![CDATA[12.900000]]></unit_price_tax_excl>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>

 

Je sèche, je n'ai plus d'idée, et je ne trouve pas grand chose sur les webservices sur gogole...
Merci d'avance pour votre aide !

pppplus

pppplus

Bonjour à tous !

Je suis en train d'essayer d'améliorer mes scripts webservice pour mes commandes extérieures, et je galère sur quelques points.

Je vous en soumets un aujourd'hui.

J'essaie de passer une commande d'un produit avec une déclinaison.
Malheureusement, je n'y arrive pas, ça commande le produit, sans aucune déclinaison choisie.
C'est d'ailleurs étrange, car ça diminue le stock du produit en tant que tel, mais ne diminue aucune déclinaison.

Pour info, je prends le product_attribute_id dans la table ps_product_attribute

Partie PHP qui génère le XML :

                $xml->children()->children()->associations->addChild('order_rows');
                //on insert une ligne cart_row par produit
                foreach($myOrder['order_rows'] as $newP) {
                    $xml->children()->children()->associations->order_rows->addChild('order_row');
                    $xml->children()->children()->associations->order_rows->order_row->addChild('id_product', $newP['id_product']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_attribute_id', $newP['product_attribute_id']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('quantity', $newP['quantity']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_name', $newP['product_name']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_reference', $newP['product_reference']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_ean13', $newP['product_ean13']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_upc', $newP['product_upc']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_price', $newP['product_price']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_incl', $newP['unit_price_tax_incl']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_excl', $newP['unit_price_tax_excl']);
                }

 

Ensuite, ça me sort bien le XML voulu :
 

Array
(
    [resource] => orders
    [postXml] => <!--?xml version="1.0" encoding="UTF-8"?-->
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>48</id_address_delivery>
	<id_address_invoice>48</id_address_invoice>
	<id_cart>49</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>45</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-620378</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13><product_upc><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></product_upc></product_ean13></order_row></order_rows></associations>
</order>
</prestashop>

)

 

Sauf qu'après envoie de
$xml = $webService->add( $opt );
L'id de l'attribut n'est pas pris en compte.

Le debug webservice me renvoie :

Array
(
    [resource] =&gt; orders
    [postXml] =&gt; <!--?xml version="1.0" encoding="UTF-8"?-->
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>48</id_address_delivery>
	<id_address_invoice>48</id_address_invoice>
	<id_cart>49</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>45</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>zonzon test1-620378</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13><product_upc><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></product_upc></product_ean13></order_row></order_rows></associations>
</order>
</prestashop>

)

 

Je sèche, je n'ai plus d'idée, et je ne trouve pas grand chose sur les webservices sur gogole...
Merci d'avance pour votre aide !

pppplus

pppplus

Bonjour à tous !

Je suis en train d'essayer d'améliorer mes scripts webservice pour mes commandes extérieures, et je galère sur quelques points.

Je vous en soumets un aujourd'hui.

J'essaie de passer une commande d'un produit avec une déclinaison.
Malheureusement, je n'y arrive pas, ça commande le produit, sans aucune déclinaison choisie.
C'est d'ailleurs étrange, car ça diminue le stock du produit en tant que tel, mais ne diminue aucune déclinaison.

Pour info, je prends le product_attribute_id dans la table ps_product_attribute

Partie PHP qui génère le XML :

                $xml->children()->children()->associations->addChild('order_rows');
                //on insert une ligne cart_row par produit
                foreach($myOrder['order_rows'] as $newP) {
                    $xml->children()->children()->associations->order_rows->addChild('order_row');
                    $xml->children()->children()->associations->order_rows->order_row->addChild('id_product', $newP['id_product']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_attribute_id', $newP['product_attribute_id']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('quantity', $newP['quantity']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_name', $newP['product_name']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_reference', $newP['product_reference']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_ean13', $newP['product_ean13']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_upc', $newP['product_upc']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('product_price', $newP['product_price']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_incl', $newP['unit_price_tax_incl']);
                    $xml->children()->children()->associations->order_rows->order_row->addChild('unit_price_tax_excl', $newP['unit_price_tax_excl']);
                }

 

Ensuite, ça me sort bien le XML voulu :
 

Array
(
    [resource] =&gt; orders
    [postXml] =&gt; <!--?xml version="1.0" encoding="UTF-8"?-->
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery>48</id_address_delivery>
	<id_address_invoice>48</id_address_invoice>
	<id_cart>49</id_cart>
	<id_currency>1</id_currency>
	<id_lang>1</id_lang>
	<id_customer>45</id_customer>
	<id_carrier>3</id_carrier>
	<current_state>10</current_state>
	<module>ps_wirepayment</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></shipping_number>
	<id_shop_group>1</id_shop_group>
	<id_shop>1</id_shop>
	<secure_key></secure_key>
	<payment>Amazon test1-620378</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>10.99</total_paid>
	<total_paid_tax_incl>10.99</total_paid_tax_incl>
	<total_paid_tax_excl>10.99</total_paid_tax_excl>
	<total_paid_real>10.99</total_paid_real>
	<total_products>9.7</total_products>
	<total_products_wt>9.7</total_products_wt>
	<total_shipping>4.49</total_shipping>
	<total_shipping_tax_incl>4.49</total_shipping_tax_incl>
	<total_shipping_tax_excl>4.49</total_shipping_tax_excl>
	<carrier_tax_rate>0</carrier_tax_rate>
	<total_wrapping>0</total_wrapping>
	<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
	<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
	<round_mode></round_mode>
	<round_type></round_type>
	<conversion_rate>1</conversion_rate>
	<reference></reference>
<associations>

<order_rows><order_row><id_product>17</id_product><product_attribute_id>35</product_attribute_id><quantity>1</quantity><product_name>Carnet de notes Ours brun</product_name><product_reference>demo_9</product_reference><product_ean13><product_upc><product_price>0</product_price><unit_price_tax_incl>0</unit_price_tax_incl><unit_price_tax_excl>0</unit_price_tax_excl></product_upc></product_ean13></order_row></order_rows></associations>
</order>
</prestashop>

)

 

Sauf qu'après envoie de
$xml = $webService->add( $opt );
L'id de l'attribut n'est pas pris en compte.

Le debug webservice me renvoie :

RETURN HTTP BODY

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
	<id></id>
	<id_address_delivery></id_address_delivery>
	<id_address_invoice></id_address_invoice>
	<id_cart></id_cart>
	<id_currency></id_currency>
	<id_lang></id_lang>
	<id_customer></id_customer>
	<id_carrier></id_carrier>
	<current_state></current_state>
	<module></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></shipping_number>
	<id_shop_group></id_shop_group>
	<id_shop></id_shop>
	<secure_key></secure_key>
	<payment></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></total_paid>
	<total_paid_tax_incl></total_paid_tax_incl>
	<total_paid_tax_excl></total_paid_tax_excl>
	<total_paid_real></total_paid_real>
	<total_products></total_products>
	<total_products_wt></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></conversion_rate>
	<reference></reference>
<associations>
<order_rows>
	<order_row>
	<id></id>
	<product_id></product_id>
	<product_attribute_id></product_attribute_id>
	<product_quantity></product_quantity>
	<product_name></product_name>
	<product_reference></product_reference>
	<product_ean13></product_ean13>
	<product_isbn></product_isbn>
	<product_upc></product_upc>
	<product_price></product_price>
	<unit_price_tax_incl></unit_price_tax_incl>
	<unit_price_tax_excl></unit_price_tax_excl>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>

 

Je sèche, je n'ai plus d'idée, et je ne trouve pas grand chose sur les webservices sur gogole...
Merci d'avance pour votre aide !

×
×
  • Create New...