makoso Posted March 14, 2017 Share Posted March 14, 2017 Hi,tooday i have to create order via web service i know i must create the cart and the next step is order. But final i have error called from OrderDetailCore->create() because what i see my cart didnt have any products. I rly dont know how i must build structure of xml to get cart inserting correctly, actualy cart is creating but without product. Product is active, have stock.How i create cart: $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, true);$xml = $webService->get( array( 'url' => PS_SHOP_PATH .'api/carts?schema=blank' ) );$xml->cart->id_currency = 1;$xml->cart->id_lang = 1;$xml->cart->id_address_delivery = 7;$xml->cart->id_address_invoice = 7;$xml->cart->id_customer = 5;$xml->cart->carrier = 2;$xml->cart->date_add = date('Y-m-d H:i:s');$xml->cart->date_upd = date('Y-m-d H:i:s');$xml->cart->associations->cart_rows->cart_row[0]->id_product = 2;$xml->cart->associations->cart_rows->cart_row[0]->id_product_attribute = 10;$xml->cart->associations->cart_rows->cart_row[0]->quantity = 4;$opt = array( 'resource' => 'carts' );$opt['postXml'] = $xml->asXML();$xml = $webService->add( $opt );$id_cart = $xml->cart->id; And now i create order $xml = $webService->get(array('url' => PS_SHOP_PATH .'api/orders/?schema=blank'));$xml->order->id_address_delivery = 7; // Customer address$xml->order->id_address_invoice = 7;$xml->order->id_cart = $id_cart;$xml->order->id_currency = 1;$xml->order->id_lang = 1;$xml->order->id_customer = 5;$xml->order->id_carrier = 2;$xml->order->module = 'cheque';$xml->order->payment = 'Payment by check';$xml->order->total_paid = 89.000000;$xml->order->total_paid_real = 0.000000;$xml->order->total_products = 53.000000;$xml->order->total_products_wt = 53.000000;$xml->order->conversion_rate = 1;$xml->order->current_state = 2;$xml->order->total_discounts = 30.000000;$xml->order->total_discounts_tax_incl = 30.000000;$xml->order->total_discounts_tax_excl = 30.000000;$xml->order->total_paid_tax_incl = 30.000000;$xml->order->total_paid_tax_excl = 30.000000;$xml->order->total_shipping = 30.000000;$xml->order->total_shipping_tax_incl = 30.000000;$xml->order->total_shipping_tax_excl = 30.000000;$xml->order->associations->order_rows->order_row[0]->id = 1;$xml->order->associations->order_rows->order_row[0]->product_id = 2;$xml->order->associations->order_rows->order_row[0]->product_attribute_id = 10;$xml->order->associations->order_rows->order_row[0]->product_quantity = 4;$xml->order->associations->order_rows->order_row[0]->product_name = 'Blouse - Color : White, Size : M';$xml->order->associations->order_rows->order_row[0]->product_reference = 'demo_2';$xml->order->associations->order_rows->order_row[0]->product_price = 26.999852;$xml->order->associations->order_rows->order_row[0]->unit_price_tax_incl = 26.999852;$xml->order->associations->order_rows->order_row[0]->unit_price_tax_excl = 26.999852;$opt = array( 'resource' => 'orders' );$opt['postXml'] = $xml->asXML();$xml = $webService->add( $opt ); The cart and order was created without products.Can i get help here?Regards. 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