I have checked same you have done, but for me first row of product only getting create into cart. Can you please help me on this?
//associations for ($i=0; $i < sizeof($data->products); $i++) { $xml->cart->associations->cart_rows->cart_row[$i]->id_product = $data->products[$i]->id_product; $xml->cart->associations->cart_rows->cart_row[$i]->id_product_attribute =$data->products[$i]->id_product_attribute; $xml->cart->associations->cart_rows->cart_row[$i]->id_address_delivery = $data->products[$i]->id_address_delivery; $xml->cart->associations->cart_rows->cart_row[$i]->quantity = $data->products[$i]->quantity; } $opt = array( 'resource' => 'carts' ); $opt['postXml'] = $xml->asXML(); $xml = $webService->add( $opt ); $id_cart = $xml->cart->id; echo json_encode(array("success" => TRUE, "message" => ' Item added to cart successfully.', 'id_cart' => $id_cart));
My request payload sample,
{"id_address_delivery" : 48, "id_address_invoice" : 48, "id_customer" : 48, "id_carrier" : 61, "products" : [{"id_product" : 3078, "id_product_attribute" : 0, "id_address_delivery" : 48, "quantity" : 1},{"id_product" : 119, "id_product_attribute" : 59, "id_address_delivery" : 48, "quantity" : 1},{"id_product" : 3204, "id_product_attribute" : 0, "id_address_delivery" : 48, "quantity" : 1}]}