Sample code for 30+ languages & platforms
AutoIt

WiX - Get all Products in a Store

See more WiX Examples

Gets the first page of products in a store.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

; Implements the following CURL command:

; curl -X POST -H "Content-Type: application/json" \
;    -d '{
;   "includeVariants": true
;   }' https://www.wixapis.com/stores/v1/products/query

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateBool("includeVariants",True)

$oHttp.AuthToken = "ACCESS_TOKEN"

$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://www.wixapis.com/stores/v1/products/query",$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; 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

Local $sId
Local $sName
Local $slug
Local $bVisible
Local $sProductType
Local $sDescription
Local $bStockTrackInventory
Local $iStockQuantity
Local $bStockInStock
Local $sPriceCurrency
Local $iPricePrice
Local $iPriceDiscountedPrice
Local $sPriceFormattedPrice
Local $sPriceFormattedDiscountedPrice
Local $sPriceDataCurrency
Local $iPriceDataPrice
Local $iPriceDataDiscountedPrice
Local $sPriceDataFormattedPrice
Local $sPriceDataFormattedDiscountedPrice
Local $bManageVariants
Local $sProductPageUrlBase
Local $sProductPageUrlPath
Local $sNumericId
Local $sInventoryItemId
Local $sDiscountType
Local $iDiscountValue
Local $sku
Local $iWeight
Local $iJ
Local $iCount_j
Local $sText
Local $strVal

Local $iMetadataItems = $oJResp.IntOf("metadata.items")
Local $iMetadataOffset = $oJResp.IntOf("metadata.offset")
Local $iTotalResults = $oJResp.IntOf("totalResults")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("products")
While $i < $iCount_i
    $oJResp.I = $i
    $sId = $oJResp.StringOf("products[i].id")
    $sName = $oJResp.StringOf("products[i].name")
    $slug = $oJResp.StringOf("products[i].slug")
    $bVisible = $oJResp.BoolOf("products[i].visible")
    $sProductType = $oJResp.StringOf("products[i].productType")
    $sDescription = $oJResp.StringOf("products[i].description")
    $bStockTrackInventory = $oJResp.BoolOf("products[i].stock.trackInventory")
    $iStockQuantity = $oJResp.IntOf("products[i].stock.quantity")
    $bStockInStock = $oJResp.BoolOf("products[i].stock.inStock")
    $sPriceCurrency = $oJResp.StringOf("products[i].price.currency")
    $iPricePrice = $oJResp.IntOf("products[i].price.price")
    $iPriceDiscountedPrice = $oJResp.IntOf("products[i].price.discountedPrice")
    $sPriceFormattedPrice = $oJResp.StringOf("products[i].price.formatted.price")
    $sPriceFormattedDiscountedPrice = $oJResp.StringOf("products[i].price.formatted.discountedPrice")
    $sPriceDataCurrency = $oJResp.StringOf("products[i].priceData.currency")
    $iPriceDataPrice = $oJResp.IntOf("products[i].priceData.price")
    $iPriceDataDiscountedPrice = $oJResp.IntOf("products[i].priceData.discountedPrice")
    $sPriceDataFormattedPrice = $oJResp.StringOf("products[i].priceData.formatted.price")
    $sPriceDataFormattedDiscountedPrice = $oJResp.StringOf("products[i].priceData.formatted.discountedPrice")
    $bManageVariants = $oJResp.BoolOf("products[i].manageVariants")
    $sProductPageUrlBase = $oJResp.StringOf("products[i].productPageUrl.base")
    $sProductPageUrlPath = $oJResp.StringOf("products[i].productPageUrl.path")
    $sNumericId = $oJResp.StringOf("products[i].numericId")
    $sInventoryItemId = $oJResp.StringOf("products[i].inventoryItemId")
    $sDiscountType = $oJResp.StringOf("products[i].discount.type")
    $iDiscountValue = $oJResp.IntOf("products[i].discount.value")
    $sku = $oJResp.StringOf("products[i].sku")
    $iWeight = $oJResp.IntOf("products[i].weight")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].additionalInfoSections")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].ribbons")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sText = $oJResp.StringOf("products[i].ribbons[j].text")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].media.items")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].customTextFields")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].productOptions")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].collectionIds")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("products[i].collectionIds[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("products[i].variants")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend