$newrule = (object)[
"checkout" => (object)[
"email" => $cEmail,
"line_items" => [(object)[
"variant_id" => "31335443824743",
"quantity" => "1"
]],
"shipping_address" => (object)[
"first_name" => $firstName,
"last_name" => $lastName,
"address1" => $address1,
"city" => $city,
"province_code" => $province_code,
"country_code" => $country_code,
"phone" => $phone,
"zip" => $zip
]
]
];
Above is my post data that I am sending in my cURL hit. following is my cURL hit.
$access_token_url = "https://" . $query["shop"] . "/admin/api/2020-01/checkouts.json";
$mycheckOUT = curl_init($access_token_url);
curl_setopt($mycheckOUT, CURLOPT_HEADER, FALSE);
curl_setopt($mycheckOUT, CURLOPT_ENCODING, 'gzip');
curl_setopt($mycheckOUT, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($mycheckOUT, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($mycheckOUT, CURLOPT_MAXREDIRS, 3);
curl_setopt($mycheckOUT, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($mycheckOUT, CURLOPT_USERAGENT, 'My New Shopify App v.1');
curl_setopt($mycheckOUT, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($mycheckOUT, CURLOPT_TIMEOUT, 30);
curl_setopt($mycheckOUT, CURLOPT_CUSTOMREQUEST, 'POST');
// Setup headers
$request_headers[] = "X-Shopify-Access-Token: " . $shopData["access_token"];
$request_headers[] = 'Content-Type: application/json';
$request_headers[] = 'Accept-encoding: charset=utf-8';
$request_headers[] = 'Host:'. $query["shop"];
curl_setopt($mycheckOUT, CURLOPT_HTTPHEADER, $request_headers);
$newrule1 = json_encode($newrule, true);
curl_setopt ($mycheckOUT, CURLOPT_POSTFIELDS, $newrule);
$resultrule = curl_exec($mycheckOUT);
$resultrulea = json_decode($resultrule,true);
Repose of above cURL is given below:
errors: {line_items: [{variant_id: [{code: "invalid", message: "is invalid", options: []}]}]}
Yes, I am trying to pull variants which are exits in my product. see the attached image:
Yes I have tried to pull other variants with same code.
Please check it and help me.