Hi @Milind2
Can you post the body and variables of your call? The error that it is throwing is nil can't be coerced into Float. Can you let me know if you are still able to replicate? I know we pushed some changes that touched a similar aspect of the API.
Vix | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello @vix ,
Thanks for your reply.
I am using following PHP code for adding variant to the existing Order.
$token = "xxxxxxxxxxxxxx-my-store-token";
$webhook_url = "https://curbside-delivery-edz.myshopify.com/admin/api/2020-01/graphql.json";
$id = 'gid://shopify/Order/2172480225325';
$variantId = 'gid://shopify/ProductVariant/34492584820781';
$quantity = 1;
$update = <<<'json'
mutation orderEditAddVariant($id: ID!, $variantId: ID!, $quantity: Int!) {
orderEditAddVariant(id: $id, variantId: $variantId, quantity: $quantity) {
calculatedLineItem {
id
}
calculatedOrder {
id
}
userErrors {
field
message
}
}
}
json;
$post_data = [];
$vars = [];
$vars = ['id' => $id, 'variantId' => $variantId, 'quantity' => $quantity];
$post_data['query'] = $update;
$post_data['variables'] = $vars;
$post_data = json_encode($post_data);
$cURLConnection = curl_init();
curl_setopt($cURLConnection, CURLOPT_URL, $webhook_url);
curl_setopt($cURLConnection, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_POST, 1);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-Shopify-Access-Token: '.$token
));
$resp = curl_exec($cURLConnection);
curl_close($cURLConnection);
echo $resp;
$jsonArrayResponse = json_decode($resp);
die("Graphql Test");
Hi @Milind2
Can you reproduce in GraphiQL or an API client such as Postman / Insomnia? That way it will be easier to see if the error lies in your code vs. the API. You will also need to be sure you are following the guide correctly: https://shopify.dev/tutorials/edit-an-existing-order-with-admin-api for example, the ID should be a CalculatedOrder ID.
Vix | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
User | Count |
---|---|
13 | |
12 | |
6 | |
6 | |
5 |