(JavaScript) Shopify Receive Count of All Products in a Collection
Get a count of all products of a given collection
var success = false;
var rest = new CkRest();
rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_KEY");
success = rest.Connect("chilkat.myshopify.com",443,true,true);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
var sbJson = new CkStringBuilder();
success = rest.FullRequestNoBodySb("GET","/admin/products/count.json?collection_id=841564295 ",sbJson);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
if (rest.ResponseStatusCode !== 200) {
console.log("Received error response code: " + rest.ResponseStatusCode);
console.log("Response body:");
console.log(sbJson.GetAsString());
return;
}
var json = new CkJsonObject();
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
var count;
count = json.IntOf("count");
// A sample JSON response body that is parsed by the above code:
// {
// "count": 1
// }
console.log("Example Completed.");
|