Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
ETrade
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
Lightspeed
MYOB
Magento
MercadoLibre

Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
SII Chile
SMSAPI
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Visual FoxPro) WooCommerce Update a Product

Demonstrates how to make changes to a product in WooCommerce.

For more information, see https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL loDate_created
LOCAL loDate_created_gmt
LOCAL loDate_modified
LOCAL loDate_modified_gmt
LOCAL loDate_on_sale_from
LOCAL loDate_on_sale_from_gmt
LOCAL loDate_on_sale_to
LOCAL loDate_on_sale_to_gmt
LOCAL lnIntVal
LOCAL lcSrc
LOCAL lcAlt
LOCAL lcHref
LOCAL lnId
LOCAL lcName
LOCAL lcSlug
LOCAL lcPermalink
LOCAL lcV_type
LOCAL lcStatus
LOCAL lnFeatured
LOCAL lcCatalog_visibility
LOCAL lcDescription
LOCAL lcShort_description
LOCAL lcSku
LOCAL lcPrice
LOCAL lcRegular_price
LOCAL lcSale_price
LOCAL lcPrice_html
LOCAL lnOn_sale
LOCAL lnPurchasable
LOCAL lnTotal_sales
LOCAL lnVirtual
LOCAL lnDownloadable
LOCAL lnDownload_limit
LOCAL lnDownload_expiry
LOCAL lcExternal_url
LOCAL lcButton_text
LOCAL lcTax_status
LOCAL lcTax_class
LOCAL lnManage_stock
LOCAL lcStock_quantity
LOCAL lcStock_status
LOCAL lcBackorders
LOCAL lnBackorders_allowed
LOCAL lnBackordered
LOCAL lnSold_individually
LOCAL lcWeight
LOCAL lcDimensionsLength
LOCAL lcDimensionsWidth
LOCAL lcDimensionsHeight
LOCAL lnShipping_required
LOCAL lnShipping_taxable
LOCAL lcShipping_class
LOCAL lnShipping_class_id
LOCAL lnReviews_allowed
LOCAL lcAverage_rating
LOCAL lnRating_count
LOCAL lnParent_id
LOCAL lcPurchase_note
LOCAL lnMenu_order
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

* Implements the following CURL command:

* curl -X PUT https://example.com/wp-json/wc/v3/products/794 \
*     -u consumer_key:consumer_secret \
*     -H "Content-Type: application/json" \
*     -d '{
*   "regular_price": "24.54"
* }'

* Use the following online tool to generate HTTP code from a CURL command
* Convert a cURL Command to HTTP Source Code

loHttp.Login = "consumer_key"
loHttp.Password = "consumer_secret"

* Use this online tool to generate code from sample JSON:
* Generate Code to Create JSON

* The following JSON is sent in the request body.

* {
*   "regular_price": "24.54"
* }

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("regular_price","24.54")

loHttp.SetRequestHeader("Content-Type","application/json")

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)

loResp = loHttp.PTextSb("PUT","https://example.com/wp-json/wc/v3/products/794",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbRequestBody
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "id": 794,
*   "name": "Premium Quality",
*   "slug": "premium-quality-19",
*   "permalink": "https://example.com/product/premium-quality-19/",
*   "date_created": "2017-03-23T17:01:14",
*   "date_created_gmt": "2017-03-23T20:01:14",
*   "date_modified": "2017-03-23T17:01:14",
*   "date_modified_gmt": "2017-03-23T20:01:14",
*   "type": "simple",
*   "status": "publish",
*   "featured": false,
*   "catalog_visibility": "visible",
*   "description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
*   "short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
*   "sku": "",
*   "price": "24.54",
*   "regular_price": "24.54",
*   "sale_price": "",
*   "date_on_sale_from": null,
*   "date_on_sale_from_gmt": null,
*   "date_on_sale_to": null,
*   "date_on_sale_to_gmt": null,
*   "price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">&#36;</span>24.54</span>",
*   "on_sale": false,
*   "purchasable": true,
*   "total_sales": 0,
*   "virtual": false,
*   "downloadable": false,
*   "downloads": [
*   ],
*   "download_limit": -1,
*   "download_expiry": -1,
*   "external_url": "",
*   "button_text": "",
*   "tax_status": "taxable",
*   "tax_class": "",
*   "manage_stock": false,
*   "stock_quantity": null,
*   "stock_status": "instock",
*   "backorders": "no",
*   "backorders_allowed": false,
*   "backordered": false,
*   "sold_individually": false,
*   "weight": "",
*   "dimensions": {
*     "length": "",
*     "width": "",
*     "height": ""
*   },
*   "shipping_required": true,
*   "shipping_taxable": true,
*   "shipping_class": "",
*   "shipping_class_id": 0,
*   "reviews_allowed": true,
*   "average_rating": "0.00",
*   "rating_count": 0,
*   "related_ids": [
*     479,
*     387,
*     22,
*     463,
*     396
*   ],
*   "upsell_ids": [
*   ],
*   "cross_sell_ids": [
*   ],
*   "parent_id": 0,
*   "purchase_note": "",
*   "categories": [
*     {
*       "id": 9,
*       "name": "Clothing",
*       "slug": "clothing"
*     },
*     {
*       "id": 14,
*       "name": "T-shirts",
*       "slug": "t-shirts"
*     }
*   ],
*   "tags": [
*   ],
*   "images": [
*     {
*       "id": 792,
*       "date_created": "2017-03-23T14:01:13",
*       "date_created_gmt": "2017-03-23T20:01:13",
*       "date_modified": "2017-03-23T14:01:13",
*       "date_modified_gmt": "2017-03-23T20:01:13",
*       "src": "https://example.com/wp-content/uploads/2017/03/T_2_front-4.jpg",
*       "name": "",
*       "alt": ""
*     },
*     {
*       "id": 793,
*       "date_created": "2017-03-23T14:01:14",
*       "date_created_gmt": "2017-03-23T20:01:14",
*       "date_modified": "2017-03-23T14:01:14",
*       "date_modified_gmt": "2017-03-23T20:01:14",
*       "src": "https://example.com/wp-content/uploads/2017/03/T_2_back-2.jpg",
*       "name": "",
*       "alt": ""
*     }
*   ],
*   "attributes": [
*   ],
*   "default_attributes": [
*   ],
*   "variations": [
*   ],
*   "grouped_products": [
*   ],
*   "menu_order": 0,
*   "meta_data": [
*   ],
*   "_links": {
*     "self": [
*       {
*         "href": "https://example.com/wp-json/wc/v3/products/794"
*       }
*     ],
*     "collection": [
*       {
*         "href": "https://example.com/wp-json/wc/v3/products"
*       }
*     ]
*   }
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

loDate_created = CreateObject('Chilkat_9_5_0.DtObj')
loDate_created_gmt = CreateObject('Chilkat_9_5_0.DtObj')
loDate_modified = CreateObject('Chilkat_9_5_0.DtObj')
loDate_modified_gmt = CreateObject('Chilkat_9_5_0.DtObj')
loDate_on_sale_from = CreateObject('Chilkat_9_5_0.DtObj')
loDate_on_sale_from_gmt = CreateObject('Chilkat_9_5_0.DtObj')
loDate_on_sale_to = CreateObject('Chilkat_9_5_0.DtObj')
loDate_on_sale_to_gmt = CreateObject('Chilkat_9_5_0.DtObj')

lnId = loJResp.IntOf("id")
lcName = loJResp.StringOf("name")
lcSlug = loJResp.StringOf("slug")
lcPermalink = loJResp.StringOf("permalink")
loJResp.DtOf("date_created",0,loDate_created)
loJResp.DtOf("date_created_gmt",0,loDate_created_gmt)
loJResp.DtOf("date_modified",0,loDate_modified)
loJResp.DtOf("date_modified_gmt",0,loDate_modified_gmt)
lcV_type = loJResp.StringOf("type")
lcStatus = loJResp.StringOf("status")
lnFeatured = loJResp.BoolOf("featured")
lcCatalog_visibility = loJResp.StringOf("catalog_visibility")
lcDescription = loJResp.StringOf("description")
lcShort_description = loJResp.StringOf("short_description")
lcSku = loJResp.StringOf("sku")
lcPrice = loJResp.StringOf("price")
lcRegular_price = loJResp.StringOf("regular_price")
lcSale_price = loJResp.StringOf("sale_price")
loJResp.DtOf("date_on_sale_from",0,loDate_on_sale_from)
loJResp.DtOf("date_on_sale_from_gmt",0,loDate_on_sale_from_gmt)
loJResp.DtOf("date_on_sale_to",0,loDate_on_sale_to)
loJResp.DtOf("date_on_sale_to_gmt",0,loDate_on_sale_to_gmt)
lcPrice_html = loJResp.StringOf("price_html")
lnOn_sale = loJResp.BoolOf("on_sale")
lnPurchasable = loJResp.BoolOf("purchasable")
lnTotal_sales = loJResp.IntOf("total_sales")
lnVirtual = loJResp.BoolOf("virtual")
lnDownloadable = loJResp.BoolOf("downloadable")
lnDownload_limit = loJResp.IntOf("download_limit")
lnDownload_expiry = loJResp.IntOf("download_expiry")
lcExternal_url = loJResp.StringOf("external_url")
lcButton_text = loJResp.StringOf("button_text")
lcTax_status = loJResp.StringOf("tax_status")
lcTax_class = loJResp.StringOf("tax_class")
lnManage_stock = loJResp.BoolOf("manage_stock")
lcStock_quantity = loJResp.StringOf("stock_quantity")
lcStock_status = loJResp.StringOf("stock_status")
lcBackorders = loJResp.StringOf("backorders")
lnBackorders_allowed = loJResp.BoolOf("backorders_allowed")
lnBackordered = loJResp.BoolOf("backordered")
lnSold_individually = loJResp.BoolOf("sold_individually")
lcWeight = loJResp.StringOf("weight")
lcDimensionsLength = loJResp.StringOf("dimensions.length")
lcDimensionsWidth = loJResp.StringOf("dimensions.width")
lcDimensionsHeight = loJResp.StringOf("dimensions.height")
lnShipping_required = loJResp.BoolOf("shipping_required")
lnShipping_taxable = loJResp.BoolOf("shipping_taxable")
lcShipping_class = loJResp.StringOf("shipping_class")
lnShipping_class_id = loJResp.IntOf("shipping_class_id")
lnReviews_allowed = loJResp.BoolOf("reviews_allowed")
lcAverage_rating = loJResp.StringOf("average_rating")
lnRating_count = loJResp.IntOf("rating_count")
lnParent_id = loJResp.IntOf("parent_id")
lcPurchase_note = loJResp.StringOf("purchase_note")
lnMenu_order = loJResp.IntOf("menu_order")
i = 0
lnCount_i = loJResp.SizeOfArray("downloads")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("related_ids")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnIntVal = loJResp.IntOf("related_ids[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("upsell_ids")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("cross_sell_ids")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("categories")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnId = loJResp.IntOf("categories[i].id")
    lcName = loJResp.StringOf("categories[i].name")
    lcSlug = loJResp.StringOf("categories[i].slug")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("tags")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("images")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnId = loJResp.IntOf("images[i].id")
    loJResp.DtOf("images[i].date_created",0,loDate_created)
    loJResp.DtOf("images[i].date_created_gmt",0,loDate_created_gmt)
    loJResp.DtOf("images[i].date_modified",0,loDate_modified)
    loJResp.DtOf("images[i].date_modified_gmt",0,loDate_modified_gmt)
    lcSrc = loJResp.StringOf("images[i].src")
    lcName = loJResp.StringOf("images[i].name")
    lcAlt = loJResp.StringOf("images[i].alt")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("attributes")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("default_attributes")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("variations")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("grouped_products")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("meta_data")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("_links.self")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcHref = loJResp.StringOf("_links.self[i].href")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("_links.collection")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcHref = loJResp.StringOf("_links.collection[i].href")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
RELEASE loDate_created
RELEASE loDate_created_gmt
RELEASE loDate_modified
RELEASE loDate_modified_gmt
RELEASE loDate_on_sale_from
RELEASE loDate_on_sale_from_gmt
RELEASE loDate_on_sale_to
RELEASE loDate_on_sale_to_gmt


 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.