TheLousyCoder Posted May 31, 2014 Share Posted May 31, 2014 Hi all, I am trying to add an order in prestashop through webservice. I tried to with below code which is throwing an exception saying product_name is empty. Please help me with correct XML to be used for creating order. define('DEBUG', true); define('PS_SHOP_PATH', 'http://localhost/localsouk'); define('PS_WS_AUTH_KEY', '240F0E96BEU8BOJCVBHDAG8XDTE1XLAL'); require_once('requests/PSWebServiceLibrary.php'); $psXML = <<<XML <prestashop> <cart> <id/> <id_address_delivery>3</id_address_delivery> <id_address_invoice>3</id_address_invoice> <id_currency>1</id_currency> <id_customer>2</id_customer> <id_guest>0</id_guest> <id_lang>2</id_lang> <id_carrier>8</id_carrier> <recyclable>1</recyclable> <gift>0</gift> <gift_message/> <associations> <cart_rows> <cart_row> <id_product>10</id_product> <id_product_attribute>39</id_product_attribute> <quantity>1</quantity> </cart_row> </cart_rows> </associations> </cart> </prestashop> XML; $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml = new SimpleXMLElement($psXML); $opt = array( 'resource' => 'carts' ); $opt['postXml'] = $xml->asXML(); $xml = $webService->add( $opt ); $psXML22 =' <prestashop> <order> <id_address_delivery>3</id_address_delivery> <id_address_invoice>3</id_address_invoice> <id_cart>'.$xml->cart->id.'</id_cart> <id_currency>1</id_currency> <id_lang>2</id_lang> <id_customer>2</id_customer> <id_carrier>8</id_carrier> <current_state>1</current_state> <module>prepaid</module> <payment>ccavenue</payment> <valid>1</valid> <id_shop>1</id_shop> <secure_key>6bb61e3b7bce0931da574d19d1d82c88</secure_key> <recyclable>1</recyclable> <gift>0</gift> <gift_message></gift_message> <total_discounts_tax_incl>11</total_discounts_tax_incl> <total_discounts_tax_excl>10</total_discounts_tax_excl> <total_paid>1111</total_paid> <total_paid_tax_incl>1111</total_paid_tax_incl> <total_paid_tax_excl>1100</total_paid_tax_excl> <total_paid_real>1111</total_paid_real> <total_products>12</total_products> <total_products_wt>1110</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> <shipping_number></shipping_number> <conversion_rate>1</conversion_rate> <reference></reference> <OrderDetail> <product_id>10</product_id> <product_attribute_id>39</product_attribute_id> <product_quantity>1</product_quantity> <product_name>chronostoarart</product_name> <product_price>1110</product_price> <unit_price_tax_incl></unit_price_tax_incl> <unit_price_tax_excl></unit_price_tax_excl> </OrderDetail> </order> </prestashop> '; $webService2 = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml2 = new SimpleXMLElement($psXML22); $opt2 = array( 'resource' => 'orders' ); $opt2['postXml'] = $xml2->asXML(); $xml3 = $webService->add( $opt2 ); Link to comment Share on other sites More sharing options...
Recommended Posts