Draft Order API Call

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"; //continue; /*for ($c=0; $c < $num; $c++) { echo $data[2] . "
\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); ?>

Rather than posting the code you’re using, what is the actual data being sent? That will be much easier to review.

I want to add multiple line items in draft order app call i need for logic

This does not appear to concern versioning, I’m moving this to the APIs and SDKs board.

Edit

Technical difficulties doing so. For now, let me address your question:

It looks like you’re halfway to your answer. Your code would probably look like this instead:

"line_items" => array(
           array("title" => $title,
            "price" => $price,
            "quantity" => $quantity,
            "taxable" => false,
            "tax_exempt" => false,
            "taxes_included" => false,
            "tax_lines"  => false),
          array("title" => $title,
            "price" => $price,
            "quantity" => $quantity,
            "taxable" => false,
            "tax_exempt" => false,
            "taxes_included" => false,
            "tax_lines"  => false)
),

You need to provide a standard array of key/value objects, which it seems are also considered arrays in PHP. I’m not a PHP expert so the syntax might not be great, but the concept still applies.