Sample code for 30+ languages & platforms
Lianja

Shopify Receive Count of All Products in a Collection

See more Shopify Examples

Get a count of all products of a given collection

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loRest = createobject("CkRest")

loRest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_KEY")

llSuccess = loRest.Connect("chilkat.myshopify.com",443,.T.,.T.)
if (llSuccess <> .T.) then
    ? loRest.LastErrorText
    release loRest
    return
endif

loSbJson = createobject("CkStringBuilder")
llSuccess = loRest.FullRequestNoBodySb("GET","/admin/products/count.json?collection_id=841564295 ",loSbJson)
if (llSuccess <> .T.) then
    ? loRest.LastErrorText
    release loRest
    release loSbJson
    return
endif

if (loRest.ResponseStatusCode <> 200) then
    ? "Received error response code: " + str(loRest.ResponseStatusCode)
    ? "Response body:"
    ? loSbJson.GetAsString()
    release loRest
    release loSbJson
    return
endif

loJson = createobject("CkJsonObject")
loJson.LoadSb(loSbJson)

// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.

lnCount = loJson.IntOf("count")

// A sample JSON response body that is parsed by the above code:

// {
//   "count": 1
// }

? "Example Completed."


release loRest
release loSbJson
release loJson