Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) WooCommerce Delete a ProductSee more WooCommerce ExamplesDemonstrates how to delete a product from WooCommerce. For more information, see https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-product
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; Implements the following CURL command: ; curl -X DELETE https://example.com/wp-json/wc/v3/products/794?force=true \ ; -u consumer_key:consumer_secret ; Use the following online tool to generate HTTP code from a CURL command ; Convert a cURL Command to HTTP Source Code $oHttp.BasicAuth = True $oHttp.Login = "consumer_key" $oHttp.Password = "consumer_secret" Local $oResp = $oHttp.QuickRequest("DELETE","https://example.com/wp-json/wc/v3/products/794?force=true") If ($oHttp.LastMethodSuccess = 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) ; { ; "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\">$</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 $oDate_created = ObjCreate("Chilkat.DtObj") $oDate_created_gmt = ObjCreate("Chilkat.DtObj") $oDate_modified = ObjCreate("Chilkat.DtObj") $oDate_modified_gmt = ObjCreate("Chilkat.DtObj") $oDate_on_sale_from = ObjCreate("Chilkat.DtObj") $oDate_on_sale_from_gmt = ObjCreate("Chilkat.DtObj") $oDate_on_sale_to = ObjCreate("Chilkat.DtObj") $oDate_on_sale_to_gmt = ObjCreate("Chilkat.DtObj") Local $intVal Local $src Local $sAlt Local $sHref Local $id = $oJResp.IntOf("id") Local $sName = $oJResp.StringOf("name") Local $slug = $oJResp.StringOf("slug") Local $sPermalink = $oJResp.StringOf("permalink") $oJResp.DtOf("date_created",False,$oDate_created) $oJResp.DtOf("date_created_gmt",False,$oDate_created_gmt) $oJResp.DtOf("date_modified",False,$oDate_modified) $oJResp.DtOf("date_modified_gmt",False,$oDate_modified_gmt) Local $sV_type = $oJResp.StringOf("type") Local $status = $oJResp.StringOf("status") Local $bFeatured = $oJResp.BoolOf("featured") Local $sCatalog_visibility = $oJResp.StringOf("catalog_visibility") Local $sDescription = $oJResp.StringOf("description") Local $short_description = $oJResp.StringOf("short_description") Local $sku = $oJResp.StringOf("sku") Local $sPrice = $oJResp.StringOf("price") Local $sRegular_price = $oJResp.StringOf("regular_price") Local $sale_price = $oJResp.StringOf("sale_price") $oJResp.DtOf("date_on_sale_from",False,$oDate_on_sale_from) $oJResp.DtOf("date_on_sale_from_gmt",False,$oDate_on_sale_from_gmt) $oJResp.DtOf("date_on_sale_to",False,$oDate_on_sale_to) $oJResp.DtOf("date_on_sale_to_gmt",False,$oDate_on_sale_to_gmt) Local $sPrice_html = $oJResp.StringOf("price_html") Local $bOn_sale = $oJResp.BoolOf("on_sale") Local $bPurchasable = $oJResp.BoolOf("purchasable") Local $iTotal_sales = $oJResp.IntOf("total_sales") Local $bVirtual = $oJResp.BoolOf("virtual") Local $bDownloadable = $oJResp.BoolOf("downloadable") Local $iDownload_limit = $oJResp.IntOf("download_limit") Local $iDownload_expiry = $oJResp.IntOf("download_expiry") Local $sExternal_url = $oJResp.StringOf("external_url") Local $sButton_text = $oJResp.StringOf("button_text") Local $sTax_status = $oJResp.StringOf("tax_status") Local $sTax_class = $oJResp.StringOf("tax_class") Local $bManage_stock = $oJResp.BoolOf("manage_stock") Local $stock_quantity = $oJResp.StringOf("stock_quantity") Local $stock_status = $oJResp.StringOf("stock_status") Local $sBackorders = $oJResp.StringOf("backorders") Local $backorders_allowed = $oJResp.BoolOf("backorders_allowed") Local $backordered = $oJResp.BoolOf("backordered") Local $bSold_individually = $oJResp.BoolOf("sold_individually") Local $sWeight = $oJResp.StringOf("weight") Local $sDimensionsLength = $oJResp.StringOf("dimensions.length") Local $sDimensionsWidth = $oJResp.StringOf("dimensions.width") Local $sDimensionsHeight = $oJResp.StringOf("dimensions.height") Local $bShipping_required = $oJResp.BoolOf("shipping_required") Local $bShipping_taxable = $oJResp.BoolOf("shipping_taxable") Local $shipping_class = $oJResp.StringOf("shipping_class") Local $iShipping_class_id = $oJResp.IntOf("shipping_class_id") Local $bReviews_allowed = $oJResp.BoolOf("reviews_allowed") Local $sAverage_rating = $oJResp.StringOf("average_rating") Local $iRating_count = $oJResp.IntOf("rating_count") Local $iParent_id = $oJResp.IntOf("parent_id") Local $sPurchase_note = $oJResp.StringOf("purchase_note") Local $iMenu_order = $oJResp.IntOf("menu_order") Local $i = 0 Local $iCount_i = $oJResp.SizeOfArray("downloads") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("related_ids") While $i < $iCount_i $oJResp.I = $i $intVal = $oJResp.IntOf("related_ids[i]") $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("upsell_ids") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("cross_sell_ids") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("categories") While $i < $iCount_i $oJResp.I = $i $id = $oJResp.IntOf("categories[i].id") $sName = $oJResp.StringOf("categories[i].name") $slug = $oJResp.StringOf("categories[i].slug") $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("tags") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("images") While $i < $iCount_i $oJResp.I = $i $id = $oJResp.IntOf("images[i].id") $oJResp.DtOf("images[i].date_created",False,$oDate_created) $oJResp.DtOf("images[i].date_created_gmt",False,$oDate_created_gmt) $oJResp.DtOf("images[i].date_modified",False,$oDate_modified) $oJResp.DtOf("images[i].date_modified_gmt",False,$oDate_modified_gmt) $src = $oJResp.StringOf("images[i].src") $sName = $oJResp.StringOf("images[i].name") $sAlt = $oJResp.StringOf("images[i].alt") $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("attributes") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("default_attributes") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("variations") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("grouped_products") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("meta_data") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("_links.self") While $i < $iCount_i $oJResp.I = $i $sHref = $oJResp.StringOf("_links.self[i].href") $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("_links.collection") While $i < $iCount_i $oJResp.I = $i $sHref = $oJResp.StringOf("_links.collection[i].href") $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.