DataFlex
DataFlex
WiX - Get all Products in a Store
See more WiX Examples
Gets the first page of products in a store.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sName
String sSlug
Boolean iVisible
String sProductType
String sDescription
Boolean iStockTrackInventory
Integer iStockQuantity
Boolean iStockInStock
String sPriceCurrency
Integer iPricePrice
Integer iPriceDiscountedPrice
String sPriceFormattedPrice
String sPriceFormattedDiscountedPrice
String sPriceDataCurrency
Integer iPriceDataPrice
Integer iPriceDataDiscountedPrice
String sPriceDataFormattedPrice
String sPriceDataFormattedDiscountedPrice
Boolean iManageVariants
String sProductPageUrlBase
String sProductPageUrlPath
String sNumericId
String sInventoryItemId
String sDiscountType
Integer iDiscountValue
String sSku
Integer iWeight
Integer j
Integer iCount_j
String sText
String sStrVal
Integer iMetadataItems
Integer iMetadataOffset
Integer iTotalResults
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Implements the following CURL command:
// curl -X POST -H "Content-Type: application/json" \
// -d '{
// "includeVariants": true
// }' https://www.wixapis.com/stores/v1/products/query
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateBool Of hoJson "includeVariants" True To iSuccess
Set ComAuthToken Of hoHttp To "ACCESS_TOKEN"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoJson to vJson
Get pvComObject of hoResp to vResp
Get ComHttpJson Of hoHttp "POST" "https://www.wixapis.com/stores/v1/products/query" vJson "application/json" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "products": [
// {
// "id": "58fcbb51-ff87-08ff-d97b-646726676e4a",
// "name": "webhook test",
// "slug": "webhook-test",
// "visible": true,
// "productType": "physical",
// "description": "<p>fasdf<\/p>",
// "stock": {
// "trackInventory": true,
// "quantity": 0,
// "inStock": false
// },
// "price": {
// "currency": "ILS",
// "price": 234,
// "discountedPrice": 234,
// "formatted": {
// "price": "234.00 ₪",
// "discountedPrice": "234.00 ₪"
// }
// },
// "priceData": {
// "currency": "ILS",
// "price": 234,
// "discountedPrice": 234,
// "formatted": {
// "price": "234.00 ₪",
// "discountedPrice": "234.00 ₪"
// }
// },
// "additionalInfoSections": [
// ],
// "ribbons": [
// {
// "text": "ribby"
// }
// ],
// "media": {
// "items": [
// ]
// },
// "customTextFields": [
// ],
// "manageVariants": true,
// "productOptions": [
// ],
// "productPageUrl": {
// "base": "https://www.my-website.com/",
// "path": "/product-page/webhook-test"
// },
// "numericId": "1567078000586000",
// "inventoryItemId": "a70344ae-0078-f700-2684-9b98d99891b5",
// "discount": {
// "type": "NONE",
// "value": 0
// },
// "collectionIds": [
// ],
// "variants": [
// ]
// },
// {
// "id": "6507fd67-94e5-10af-73e4-d2167852d5bc",
// "name": "digital product",
// "slug": "digital-product",
// "visible": true,
// "productType": "digital",
// "description": "",
// "sku": "",
// "weight": 0,
// "stock": {
// "trackInventory": false,
// "inStock": true
// },
// "price": {
// "currency": "ILS",
// "price": 123,
// "discountedPrice": 123,
// "formatted": {
// "price": "123.00 ₪",
// "discountedPrice": "123.00 ₪"
// }
// },
// "priceData": {
// "currency": "ILS",
// "price": 123,
// "discountedPrice": 123,
// "formatted": {
// "price": "123.00 ₪",
// "discountedPrice": "123.00 ₪"
// }
// },
// "additionalInfoSections": [
// ],
// "ribbons": [
// ],
// "media": {
// "items": [
// ]
// },
// "customTextFields": [
// ],
// "manageVariants": false,
// "productOptions": [
// ],
// "productPageUrl": {
// "base": "https://www.my-website.com/",
// "path": "/product-page/digital-product"
// },
// "numericId": "1544009414325000",
// "inventoryItemId": "9af80298-6b1a-ef50-8c1b-2de987ad2a43",
// "discount": {
// "type": "NONE",
// "value": 0
// },
// "collectionIds": [
// "ae886d55-2572-eee8-b2c4-13219844b5e4"
// ],
// "variants": [
// ]
// }
// ],
// "metadata": {
// "items": 100,
// "offset": 0
// },
// "totalResults": 2
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Get ComIntOf Of hoJResp "metadata.items" To iMetadataItems
Get ComIntOf Of hoJResp "metadata.offset" To iMetadataOffset
Get ComIntOf Of hoJResp "totalResults" To iTotalResults
Move 0 To i
Get ComSizeOfArray Of hoJResp "products" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "products[i].id" To sId
Get ComStringOf Of hoJResp "products[i].name" To sName
Get ComStringOf Of hoJResp "products[i].slug" To sSlug
Get ComBoolOf Of hoJResp "products[i].visible" To iVisible
Get ComStringOf Of hoJResp "products[i].productType" To sProductType
Get ComStringOf Of hoJResp "products[i].description" To sDescription
Get ComBoolOf Of hoJResp "products[i].stock.trackInventory" To iStockTrackInventory
Get ComIntOf Of hoJResp "products[i].stock.quantity" To iStockQuantity
Get ComBoolOf Of hoJResp "products[i].stock.inStock" To iStockInStock
Get ComStringOf Of hoJResp "products[i].price.currency" To sPriceCurrency
Get ComIntOf Of hoJResp "products[i].price.price" To iPricePrice
Get ComIntOf Of hoJResp "products[i].price.discountedPrice" To iPriceDiscountedPrice
Get ComStringOf Of hoJResp "products[i].price.formatted.price" To sPriceFormattedPrice
Get ComStringOf Of hoJResp "products[i].price.formatted.discountedPrice" To sPriceFormattedDiscountedPrice
Get ComStringOf Of hoJResp "products[i].priceData.currency" To sPriceDataCurrency
Get ComIntOf Of hoJResp "products[i].priceData.price" To iPriceDataPrice
Get ComIntOf Of hoJResp "products[i].priceData.discountedPrice" To iPriceDataDiscountedPrice
Get ComStringOf Of hoJResp "products[i].priceData.formatted.price" To sPriceDataFormattedPrice
Get ComStringOf Of hoJResp "products[i].priceData.formatted.discountedPrice" To sPriceDataFormattedDiscountedPrice
Get ComBoolOf Of hoJResp "products[i].manageVariants" To iManageVariants
Get ComStringOf Of hoJResp "products[i].productPageUrl.base" To sProductPageUrlBase
Get ComStringOf Of hoJResp "products[i].productPageUrl.path" To sProductPageUrlPath
Get ComStringOf Of hoJResp "products[i].numericId" To sNumericId
Get ComStringOf Of hoJResp "products[i].inventoryItemId" To sInventoryItemId
Get ComStringOf Of hoJResp "products[i].discount.type" To sDiscountType
Get ComIntOf Of hoJResp "products[i].discount.value" To iDiscountValue
Get ComStringOf Of hoJResp "products[i].sku" To sSku
Get ComIntOf Of hoJResp "products[i].weight" To iWeight
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].additionalInfoSections" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].ribbons" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "products[i].ribbons[j].text" To sText
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].media.items" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].customTextFields" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].productOptions" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].collectionIds" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "products[i].collectionIds[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "products[i].variants" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
End_Procedure