Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Xojo Plugin Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Xojo Plugin) WooCommerce Create a Product

See more WooCommerce Examples

Demonstrates how to create a new product in WooCommerce.

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

Chilkat Xojo Plugin Download

Xojo Plugin for Windows, Linux, Mac OS X, and ARM, ARM64

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

Dim http As New Chilkat.Http
Dim success As Boolean

// Implements the following CURL command:

// curl -X POST https://example.com/wp-json/wc/v3/products \
//     -u consumer_key:consumer_secret \
//     -H "Content-Type: application/json" \
//     -d '{
//   "name": "Premium Quality",
//   "type": "simple",
//   "regular_price": "21.99",
//   "description": "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.",
//   "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
//   "categories": [
//     {
//       "id": 9
//     },
//     {
//       "id": 14
//     }
//   ],
//   "images": [
//     {
//       "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
//     },
//     {
//       "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
//     }
//   ]
// }'

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

http.BasicAuth = True
http.Login = "consumer_key"
http.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.

// {
//   "name": "Premium Quality",
//   "type": "simple",
//   "regular_price": "21.99",
//   "description": "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.",
//   "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
//   "categories": [
//     {
//       "id": 9
//     },
//     {
//       "id": 14
//     }
//   ],
//   "images": [
//     {
//       "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
//     },
//     {
//       "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
//     }
//   ]
// }

Dim json As New Chilkat.JsonObject
success = json.UpdateString("name","Premium Quality")
success = json.UpdateString("type","simple")
success = json.UpdateString("regular_price","21.99")
success = json.UpdateString("description","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.")
success = json.UpdateString("short_description","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.")
success = json.UpdateInt("categories[0].id",9)
success = json.UpdateInt("categories[1].id",14)
success = json.UpdateString("images[0].src","http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg")
success = json.UpdateString("images[1].src","http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg")

http.SetRequestHeader "Content-Type","application/json"

Dim resp As Chilkat.HttpResponse
resp = http.PostJson3("https://example.com/wp-json/wc/v3/products","application/json",json)
If (http.LastMethodSuccess = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)
Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")

    Return
End If

// 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": "21.99",
//   "regular_price": "21.99",
//   "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>21.99</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": [
//     53,
//     40,
//     56,
//     479,
//     99
//   ],
//   "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

Dim date_created As New Chilkat.DtObj
Dim date_created_gmt As New Chilkat.DtObj
Dim date_modified As New Chilkat.DtObj
Dim date_modified_gmt As New Chilkat.DtObj
Dim date_on_sale_from As New Chilkat.DtObj
Dim date_on_sale_from_gmt As New Chilkat.DtObj
Dim date_on_sale_to As New Chilkat.DtObj
Dim date_on_sale_to_gmt As New Chilkat.DtObj
Dim intVal As Int32
Dim src As String
Dim alt As String
Dim href As String

Dim id As Int32
id = jResp.IntOf("id")
Dim name As String
name = jResp.StringOf("name")
Dim slug As String
slug = jResp.StringOf("slug")
Dim permalink As String
permalink = jResp.StringOf("permalink")
success = jResp.DtOf("date_created",False,date_created)
success = jResp.DtOf("date_created_gmt",False,date_created_gmt)
success = jResp.DtOf("date_modified",False,date_modified)
success = jResp.DtOf("date_modified_gmt",False,date_modified_gmt)
Dim v_type As String
v_type = jResp.StringOf("type")
Dim status As String
status = jResp.StringOf("status")
Dim featured As Boolean
featured = jResp.BoolOf("featured")
Dim catalog_visibility As String
catalog_visibility = jResp.StringOf("catalog_visibility")
Dim description As String
description = jResp.StringOf("description")
Dim short_description As String
short_description = jResp.StringOf("short_description")
Dim sku As String
sku = jResp.StringOf("sku")
Dim price As String
price = jResp.StringOf("price")
Dim regular_price As String
regular_price = jResp.StringOf("regular_price")
Dim sale_price As String
sale_price = jResp.StringOf("sale_price")
success = jResp.DtOf("date_on_sale_from",False,date_on_sale_from)
success = jResp.DtOf("date_on_sale_from_gmt",False,date_on_sale_from_gmt)
success = jResp.DtOf("date_on_sale_to",False,date_on_sale_to)
success = jResp.DtOf("date_on_sale_to_gmt",False,date_on_sale_to_gmt)
Dim price_html As String
price_html = jResp.StringOf("price_html")
Dim on_sale As Boolean
on_sale = jResp.BoolOf("on_sale")
Dim purchasable As Boolean
purchasable = jResp.BoolOf("purchasable")
Dim total_sales As Int32
total_sales = jResp.IntOf("total_sales")
Dim virtual As Boolean
virtual = jResp.BoolOf("virtual")
Dim downloadable As Boolean
downloadable = jResp.BoolOf("downloadable")
Dim download_limit As Int32
download_limit = jResp.IntOf("download_limit")
Dim download_expiry As Int32
download_expiry = jResp.IntOf("download_expiry")
Dim external_url As String
external_url = jResp.StringOf("external_url")
Dim button_text As String
button_text = jResp.StringOf("button_text")
Dim tax_status As String
tax_status = jResp.StringOf("tax_status")
Dim tax_class As String
tax_class = jResp.StringOf("tax_class")
Dim manage_stock As Boolean
manage_stock = jResp.BoolOf("manage_stock")
Dim stock_quantity As String
stock_quantity = jResp.StringOf("stock_quantity")
Dim stock_status As String
stock_status = jResp.StringOf("stock_status")
Dim backorders As String
backorders = jResp.StringOf("backorders")
Dim backorders_allowed As Boolean
backorders_allowed = jResp.BoolOf("backorders_allowed")
Dim backordered As Boolean
backordered = jResp.BoolOf("backordered")
Dim sold_individually As Boolean
sold_individually = jResp.BoolOf("sold_individually")
Dim weight As String
weight = jResp.StringOf("weight")
Dim dimensionsLength As String
dimensionsLength = jResp.StringOf("dimensions.length")
Dim dimensionsWidth As String
dimensionsWidth = jResp.StringOf("dimensions.width")
Dim dimensionsHeight As String
dimensionsHeight = jResp.StringOf("dimensions.height")
Dim shipping_required As Boolean
shipping_required = jResp.BoolOf("shipping_required")
Dim shipping_taxable As Boolean
shipping_taxable = jResp.BoolOf("shipping_taxable")
Dim shipping_class As String
shipping_class = jResp.StringOf("shipping_class")
Dim shipping_class_id As Int32
shipping_class_id = jResp.IntOf("shipping_class_id")
Dim reviews_allowed As Boolean
reviews_allowed = jResp.BoolOf("reviews_allowed")
Dim average_rating As String
average_rating = jResp.StringOf("average_rating")
Dim rating_count As Int32
rating_count = jResp.IntOf("rating_count")
Dim parent_id As Int32
parent_id = jResp.IntOf("parent_id")
Dim purchase_note As String
purchase_note = jResp.StringOf("purchase_note")
Dim menu_order As Int32
menu_order = jResp.IntOf("menu_order")
Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jResp.SizeOfArray("downloads")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("related_ids")
While i < count_i
    jResp.I = i
    intVal = jResp.IntOf("related_ids[i]")
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("upsell_ids")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("cross_sell_ids")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("categories")
While i < count_i
    jResp.I = i
    id = jResp.IntOf("categories[i].id")
    name = jResp.StringOf("categories[i].name")
    slug = jResp.StringOf("categories[i].slug")
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("tags")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("images")
While i < count_i
    jResp.I = i
    id = jResp.IntOf("images[i].id")
    success = jResp.DtOf("images[i].date_created",False,date_created)
    success = jResp.DtOf("images[i].date_created_gmt",False,date_created_gmt)
    success = jResp.DtOf("images[i].date_modified",False,date_modified)
    success = jResp.DtOf("images[i].date_modified_gmt",False,date_modified_gmt)
    src = jResp.StringOf("images[i].src")
    name = jResp.StringOf("images[i].name")
    alt = jResp.StringOf("images[i].alt")
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("attributes")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("default_attributes")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("variations")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("grouped_products")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("meta_data")
While i < count_i
    jResp.I = i
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("_links.self")
While i < count_i
    jResp.I = i
    href = jResp.StringOf("_links.self[i].href")
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("_links.collection")
While i < count_i
    jResp.I = i
    href = jResp.StringOf("_links.collection[i].href")
    i = i + 1
Wend

 

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