Unable to add lineitems to checkout using checkout api

sardarusama4106
Tourist
15 0 0

I'm trying to create a checkout using Checkout API, my app is a sales channel and has the access of "writing_checkouts". The product is listed on the sales channel but when I try to create a checkout, the request-response in 200, return a complete checkout object, but there is no field added like email, line_items or shipping address. Here is the example code:

 $field = array(
      "checkout"=>array(
        "email"=> "john.smith@example.com",
        "line_items"=> array(array(
          "variant_id"=> 31520093667373,
          "quantity"=> 1
        )),
        "shipping_address"=> array(
          "first_name"=> "John",
          "last_name"=> "Smith",
          "address1"=> "126 York St.",
          "city"=> "Ottawa",
          "province_code"=> "ON",
          "country_code"=> "CA",
          "phone"=> "(123)456-7890",
          "zip"=> "K1N 5T5"
        )
      )
    );
    $data = json_encode($field);
    $url=$shopUrl.'/checkouts.json';
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => array(
            "Authorization: Basic Og==",
            "accept: application/json",
            "content-type: application/graphql",
            "X-Shopify-Access-Token: ********************************",
        ),
        CURLOPT_POSTFIELDS=> $postFields
    ));    
    $response = curl_exec($curl);
    $err = curl_error($curl);    
    curl_close($curl);
    if ($err) {
        echo $err;
    } else {
        echo $response;
    }

and this is the response I'm gettin:

{"checkout":
{"completed_at":null,
"created_at":"2019-12-24T00:02:15-05:00", 
"currency":"PKR",
"presentment_currency":"PKR",
"customer_id":null,
"email":null,
"name":"#11978400727085","note":"",
"order_id":null,
"order_status_url":null,
"subtotal_price":"0.00",
"token":"*******************************",
"total_price":"0.00",
"total_tax":"0.00",
"total_tip_received":"0.00",
"total_line_items_price":"0.00",
"updated_at":"2019-12-24T00:02:15-05:00",
"user_id":null,
"line_items":[],
"gift_cards":[],
"tax_lines":[],
"shipping_line":null,
"shipping_rate":null,
"shipping_address":null,
"credit_card":null,
"billing_address":null,
"applied_discount":null}
}
Reply 1 (1)

sd_
Shopify Staff (Retired)
51 10 7

Hi there, 

 

If you are still experiencing this issue, would you be able to provide the 'x-request-id' header from the response to any of the requests you have made to the Checkout API. This will allow me to check our internal logs. 

 

Thanks 

To learn more visit the Shopify Help Center or the Community Blog.