avatarusswtor Posted April 18, 2015 Share Posted April 18, 2015 0 down vote favorite Im trying to create order in Prestashop 1.6.0.14 Client, adress, cars are created successful but I cant create order and dont know Why. Here is code for order creation $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml = new SimpleXMLElement($psXML); $opt = array( 'resource' => 'orders' ); $opt['postXml'] = $xml->asXML(); $xml = $webService->add( $opt ); and here is XML Im passing: <?xml version="1.0" encoding="UTF-8"?><prestashop> <order> <id_address_delivery>175</id_address_delivery> <id_cart>286</id_cart> <id_currency>1</id_currency> <id_lang>1</id_lang> <id_customer>191</id_customer> <id_carrier>8</id_carrier> <current_state>14</current_state> <module>Bankwire</module> <date_add>2015-04-18 11:04:42</date_add> <id_shop_group>1</id_shop_group> <id_shop>1</id_shop> <payment>przelew na konto</payment> <total_discounts>0.00</total_discounts> <total_discounts_tax_incl>0.00</total_discounts_tax_incl> <total_discounts_tax_excl>0.00</total_discounts_tax_excl> <total_paid>60.5</total_paid> <total_paid_tax_incl>60.5</total_paid_tax_incl> <total_paid_tax_excl>46.2</total_paid_tax_excl> <total_paid_real>60.5</total_paid_real> <total_products>44</total_products> <total_products_wt>44</total_products_wt> <total_shipping>16</total_shipping> <total_shipping_tax_incl>16</total_shipping_tax_incl> <total_shipping_tax_excl>12.32</total_shipping_tax_excl> <carrier_tax_rate>1</carrier_tax_rate> <total_wrapping>0.00</total_wrapping> <total_wrapping_tax_incl>0.00</total_wrapping_tax_incl> <total_wrapping_tax_excl>0.00</total_wrapping_tax_excl> <round_mode>2</round_mode> </order> </prestashop> Im getting error: Internal error. To see this error please display the PHP errors. Other error This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request. Can anybody help mi with that? Im searching help on google, forums, stack, and nothing. I realy need this to finaly be able to import orders form allegro to prestashop Link to comment Share on other sites More sharing options...
An'im Fahmy Posted September 7, 2015 Share Posted September 7, 2015 Please help,,, Also same problem This is my xml <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order> <id></id> <id_address_delivery>5047</id_address_delivery> <id_address_invoice>5047</id_address_invoice> <id_cart>35</id_cart> <id_currency>1</id_currency> <id_lang>1</id_lang> <id_customer>34</id_customer> <id_carrier>60</id_carrier> <current_state>59</current_state> <module>bca</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>BCA</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>196000</total_paid> <total_paid_tax_incl></total_paid_tax_incl> <total_paid_tax_excl></total_paid_tax_excl> <total_paid_real>196000</total_paid_real> <total_products>196000</total_products> <total_products_wt>196000</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>1</conversion_rate> <reference></reference> <associations> <order_rows> <order_row> <product_id>3</product_id> <product_attribute_id>0</product_attribute_id> <product_quantity>4</product_quantity> </order_row> <order_row> <product_id>6</product_id> <product_attribute_id>0</product_attribute_id> <product_quantity>4</product_quantity> </order_row> </order_rows> </associations> </order> </prestashop> {"status":"Other error <br \/>Bad parameters given"} Why bad parameters? All required is not empty. Thank you, Link to comment Share on other sites More sharing options...
AbdullahBasit Posted December 31, 2015 Share Posted December 31, 2015 $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/customers/?schema=synopsis')); $customer = array(); $product = array(); if (!empty(Tools::getValue('c_email'))) $customer['email'] = Tools::getValue('c_email'); else $customer['email'] = '[email protected]'; $customer['firstname'] = Tools::getValue('fname'); $customer['lastname'] = Tools::getValue('lname'); $customer['address1'] = Tools::getValue('c_address'); $customer['city'] = Tools::getValue('c_city'); $customer['phone'] = Tools::getValue('c_phone'); $id['country'] = '165'; $id['lang'] = '1'; $id['currency'] = '1'; $id['carrier'] = '3'; $product['quantity'] = Tools::getValue('c_qty'); $product['id'] = $id_product; $product['price'] = Product::getPriceStatic($product['id']); $product['name'] = Product::getProductName($product['id']); $product['total'] = $product['price'] * $product['quantity']; $xml->customer->firstname = $customer['firstname']; $xml->customer->lastname = $customer['lastname']; $xml->customer->email = $customer['email']; $xml->customer->newsletter = '1'; $xml->customer->optin = '1'; $xml->customer->active = '1'; $opt = array('resource' => 'customers'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); // ID of created customer $id['customer'] = $xml->customer->id; // CREATE Address $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/addresses?schema=synopsis')); $xml->address->id_customer = $id['customer']; $xml->address->firstname = $customer['firstname']; $xml->address->lastname = $customer['lastname']; $xml->address->address1 = $customer['address1']; $xml->address->city = $customer['city']; $xml->address->phone_mobile = $customer['phone']; $xml->address->id_country = $id['country']; $xml->address->alias = '-'; $opt = array('resource' => 'addresses'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); // ID of created address $id['address'] = $xml->address->id; // CREATE Cart $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/carts?schema=blank')); $xml->cart->id_customer = $id['customer']; $xml->cart->id_address_delivery = $id['address']; $xml->cart->id_address_invoice = $id['address']; $xml->cart->id_currency = $id['currency']; $xml->cart->id_lang = $id['lang']; $xml->cart->id_carrier = $id['carrier']; $xml->cart->associations->cart_rows->cart_row->id_product = $product['id']; $xml->cart->associations->cart_rows->cart_row->quantity = $product['quantity']; if(!empty(Tools::getValue('product_attr'))) $xml->cart->associations->cart_rows->cart_row->id_product_attribute = Tools::getValue('product_attr'); $opt = array('resource' => 'carts'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); // ID of created cart $id['cart'] = $xml->cart->id; // CREATE Order $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/orders?schema=blank')); $xml->order->id_customer = $id['customer']; $xml->order->id_address_delivery = $id['address']; $xml->order->id_address_invoice = $id['address']; $xml->order->id_cart = $id['cart']; $xml->order->id_currency = $id['currency']; $xml->order->id_lang = $id['lang']; $xml->order->id_carrier = 3; $xml->order->current_state = 3; $xml->order->valid = 0; $xml->order->payment = 'Cash on delivery'; $xml->order->module = 'cashondelivery'; $xml->order->total_paid = $product['total']; $xml->order->total_paid_tax_incl = $product['total']; $xml->order->total_paid_tax_excl = $product['total']; $xml->order->total_paid_real = '0'; $xml->order->total_products = $product['total']; $xml->order->total_products_wt = $product['total']; $xml->order->conversion_rate = '1'; $xml->order->associations->order_rows->order_row->product_id = $product['id']; $xml->order->associations->order_rows->order_row->product_quantity = $product['quantity']; $opt = array('resource' => 'orders'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); $id['order'] = $xml->order->id; $id['secure_key'] = $xml->order->secure_key; $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/order_histories?schema=blank')); $xml->order_history->id_order = $id['order']; $xml->order_history->id_order_state = '3'; $opt = array('resource' => 'order_histories'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now