PowerBuilder
PowerBuilder
WiX - Get all Products in a Store
See more WiX Examples
Gets the first page of products in a store.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_Name
string ls_Slug
integer li_Visible
string ls_ProductType
string ls_Description
integer li_StockTrackInventory
integer li_StockQuantity
integer li_StockInStock
string ls_PriceCurrency
integer li_PricePrice
integer li_PriceDiscountedPrice
string ls_PriceFormattedPrice
string ls_PriceFormattedDiscountedPrice
string ls_PriceDataCurrency
integer li_PriceDataPrice
integer li_PriceDataDiscountedPrice
string ls_PriceDataFormattedPrice
string ls_PriceDataFormattedDiscountedPrice
integer li_ManageVariants
string ls_ProductPageUrlBase
string ls_ProductPageUrlPath
string ls_NumericId
string ls_InventoryItemId
string ls_DiscountType
integer li_DiscountValue
string ls_Sku
integer li_Weight
integer j
integer li_Count_j
string ls_Text
string ls_StrVal
integer li_MetadataItems
integer li_MetadataOffset
integer li_TotalResults
integer i
integer li_Count_i
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Implements the following CURL command:
// curl -X POST -H "Content-Type: application/json" \
// -d '{
// "includeVariants": true
// }' https://www.wixapis.com/stores/v1/products/query
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateBool("includeVariants",1)
loo_Http.AuthToken = "ACCESS_TOKEN"
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpJson("POST","https://www.wixapis.com/stores/v1/products/query",loo_Json,"application/json",loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_Resp
return
end if
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Http
destroy loo_Json
destroy loo_Resp
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// 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
li_MetadataItems = loo_JResp.IntOf("metadata.items")
li_MetadataOffset = loo_JResp.IntOf("metadata.offset")
li_TotalResults = loo_JResp.IntOf("totalResults")
i = 0
li_Count_i = loo_JResp.SizeOfArray("products")
do while i < li_Count_i
loo_JResp.I = i
ls_Id = loo_JResp.StringOf("products[i].id")
ls_Name = loo_JResp.StringOf("products[i].name")
ls_Slug = loo_JResp.StringOf("products[i].slug")
li_Visible = loo_JResp.BoolOf("products[i].visible")
ls_ProductType = loo_JResp.StringOf("products[i].productType")
ls_Description = loo_JResp.StringOf("products[i].description")
li_StockTrackInventory = loo_JResp.BoolOf("products[i].stock.trackInventory")
li_StockQuantity = loo_JResp.IntOf("products[i].stock.quantity")
li_StockInStock = loo_JResp.BoolOf("products[i].stock.inStock")
ls_PriceCurrency = loo_JResp.StringOf("products[i].price.currency")
li_PricePrice = loo_JResp.IntOf("products[i].price.price")
li_PriceDiscountedPrice = loo_JResp.IntOf("products[i].price.discountedPrice")
ls_PriceFormattedPrice = loo_JResp.StringOf("products[i].price.formatted.price")
ls_PriceFormattedDiscountedPrice = loo_JResp.StringOf("products[i].price.formatted.discountedPrice")
ls_PriceDataCurrency = loo_JResp.StringOf("products[i].priceData.currency")
li_PriceDataPrice = loo_JResp.IntOf("products[i].priceData.price")
li_PriceDataDiscountedPrice = loo_JResp.IntOf("products[i].priceData.discountedPrice")
ls_PriceDataFormattedPrice = loo_JResp.StringOf("products[i].priceData.formatted.price")
ls_PriceDataFormattedDiscountedPrice = loo_JResp.StringOf("products[i].priceData.formatted.discountedPrice")
li_ManageVariants = loo_JResp.BoolOf("products[i].manageVariants")
ls_ProductPageUrlBase = loo_JResp.StringOf("products[i].productPageUrl.base")
ls_ProductPageUrlPath = loo_JResp.StringOf("products[i].productPageUrl.path")
ls_NumericId = loo_JResp.StringOf("products[i].numericId")
ls_InventoryItemId = loo_JResp.StringOf("products[i].inventoryItemId")
ls_DiscountType = loo_JResp.StringOf("products[i].discount.type")
li_DiscountValue = loo_JResp.IntOf("products[i].discount.value")
ls_Sku = loo_JResp.StringOf("products[i].sku")
li_Weight = loo_JResp.IntOf("products[i].weight")
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].additionalInfoSections")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].ribbons")
do while j < li_Count_j
loo_JResp.J = j
ls_Text = loo_JResp.StringOf("products[i].ribbons[j].text")
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].media.items")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].customTextFields")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].productOptions")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].collectionIds")
do while j < li_Count_j
loo_JResp.J = j
ls_StrVal = loo_JResp.StringOf("products[i].collectionIds[j]")
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("products[i].variants")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
i = i + 1
loop
destroy loo_Http
destroy loo_Json
destroy loo_Resp
destroy loo_SbResponseBody
destroy loo_JResp