How to pass multiple line items in draft orders post request api call ,
Single Line item Ok but i need how to add multiple line_tems to object array Please replay me ASAP.
<?php $title; $price; $quantity; $row = 1; if (($handle = fopen("Stumak.csv", "r")) !== FALSE) { fgetcsv($handle, 10000, ","); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo $num; //echo " $num fields in line $row:
\n"; }*/ $title= $data[0]; //echio $title; $quantity=$data[1]; $price=$data[2]; $data = array("draft_order" => array( "line_items" => array( "title" => $title, "price" => $price, "quantity" => $quantity, "taxable" => false, "tax_exempt" => false, "taxes_included" => false, "tax_lines" => false, ), )); $data_string = json_encode($data); $ch = curl_init('https://e3d5dbb3946465ae26dc116fc9546e90:b792b6c8c8eaa3dc3924e7cacd889e79@fisssion-bottle-club.myshopify.com/admin/draft_orders.json'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); print_r($result); curl_close($ch); //$result=json_decode($result,true); //echo $result["draft_order"]["id"]; } } exit; $data = array("draft_order" => array( "customer" =>array( //"id" => 616685502563 // "id" => 935647477859 "id" => 1770247848013 ), "note_attributes" => array(array( "name" => "Invoice Due Date", "value" => "2019-05-01" )), "use_customer_default_address"=>true )); $data_string = json_encode($data); //$ch = curl_init('https://0689b3bd0517127cf9829c91620e0267:a5cc8b541959f3324d54af0ee7e91afb@men-varaosat-oy.myshopify.com/admin/draft_orders.json'); $ch = curl_init('https://e3d5dbb3946465ae26dc116fc9546e90:b792b6c8c8eaa3dc3924e7cacd889e79@fisssion-bottle-club.myshopify.com/admin/draft_orders/201853141069.json'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); print_r($result); ?>