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

MFC Web API Examples

Primary Categories

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

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
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
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(MFC) WooCommerce Delete a Product

See more WooCommerce Examples

Demonstrates how to delete a product from WooCommerce.

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

Chilkat C/C++ Library Downloads

MS Visual C/C++ Libs

See Also: Using MFC CString in Chilkat

#include <CkHttp.h>
#include <CkHttpResponse.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>
#include <CkDtObj.h>

void ChilkatSample(void)
    {
    CkString strOut;

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

    CkHttp http;
    bool success;

    // 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

    http.put_BasicAuth(true);
    http.put_Login("consumer_key");
    http.put_Password("consumer_secret");

    CkHttpResponse *resp = http.QuickRequest("DELETE","https://example.com/wp-json/wc/v3/products/794?force=true");
    if (http.get_LastMethodSuccess() == false) {
        strOut.append(http.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    CkStringBuilder sbResponseBody;
    resp->GetBodySb(sbResponseBody);
    CkJsonObject jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    strOut.append("Response Body:");
    strOut.append("\r\n");
    strOut.append(jResp.emit());
    strOut.append("\r\n");

    int respStatusCode = resp->get_StatusCode();
    strOut.append("Response Status Code = ");
    strOut.appendInt(respStatusCode);
    strOut.append("\r\n");
    if (respStatusCode >= 400) {
        strOut.append("Response Header:");
        strOut.append("\r\n");
        strOut.append(resp->header());
        strOut.append("\r\n");
        strOut.append("Failed.");
        strOut.append("\r\n");
        delete resp;
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    delete resp;

    // 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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    CkDtObj date_created;
    CkDtObj date_created_gmt;
    CkDtObj date_modified;
    CkDtObj date_modified_gmt;
    CkDtObj date_on_sale_from;
    CkDtObj date_on_sale_from_gmt;
    CkDtObj date_on_sale_to;
    CkDtObj date_on_sale_to_gmt;
    int intVal;
    const char *src = 0;
    const char *alt = 0;
    const char *href = 0;

    int id = jResp.IntOf("id");
    const char *name = jResp.stringOf("name");
    const char *slug = jResp.stringOf("slug");
    const char *permalink = jResp.stringOf("permalink");
    jResp.DtOf("date_created",false,date_created);
    jResp.DtOf("date_created_gmt",false,date_created_gmt);
    jResp.DtOf("date_modified",false,date_modified);
    jResp.DtOf("date_modified_gmt",false,date_modified_gmt);
    const char *v_type = jResp.stringOf("type");
    const char *status = jResp.stringOf("status");
    bool featured = jResp.BoolOf("featured");
    const char *catalog_visibility = jResp.stringOf("catalog_visibility");
    const char *description = jResp.stringOf("description");
    const char *short_description = jResp.stringOf("short_description");
    const char *sku = jResp.stringOf("sku");
    const char *price = jResp.stringOf("price");
    const char *regular_price = jResp.stringOf("regular_price");
    const char *sale_price = jResp.stringOf("sale_price");
    jResp.DtOf("date_on_sale_from",false,date_on_sale_from);
    jResp.DtOf("date_on_sale_from_gmt",false,date_on_sale_from_gmt);
    jResp.DtOf("date_on_sale_to",false,date_on_sale_to);
    jResp.DtOf("date_on_sale_to_gmt",false,date_on_sale_to_gmt);
    const char *price_html = jResp.stringOf("price_html");
    bool on_sale = jResp.BoolOf("on_sale");
    bool purchasable = jResp.BoolOf("purchasable");
    int total_sales = jResp.IntOf("total_sales");
    bool virtual = jResp.BoolOf("virtual");
    bool downloadable = jResp.BoolOf("downloadable");
    int download_limit = jResp.IntOf("download_limit");
    int download_expiry = jResp.IntOf("download_expiry");
    const char *external_url = jResp.stringOf("external_url");
    const char *button_text = jResp.stringOf("button_text");
    const char *tax_status = jResp.stringOf("tax_status");
    const char *tax_class = jResp.stringOf("tax_class");
    bool manage_stock = jResp.BoolOf("manage_stock");
    const char *stock_quantity = jResp.stringOf("stock_quantity");
    const char *stock_status = jResp.stringOf("stock_status");
    const char *backorders = jResp.stringOf("backorders");
    bool backorders_allowed = jResp.BoolOf("backorders_allowed");
    bool backordered = jResp.BoolOf("backordered");
    bool sold_individually = jResp.BoolOf("sold_individually");
    const char *weight = jResp.stringOf("weight");
    const char *dimensionsLength = jResp.stringOf("dimensions.length");
    const char *dimensionsWidth = jResp.stringOf("dimensions.width");
    const char *dimensionsHeight = jResp.stringOf("dimensions.height");
    bool shipping_required = jResp.BoolOf("shipping_required");
    bool shipping_taxable = jResp.BoolOf("shipping_taxable");
    const char *shipping_class = jResp.stringOf("shipping_class");
    int shipping_class_id = jResp.IntOf("shipping_class_id");
    bool reviews_allowed = jResp.BoolOf("reviews_allowed");
    const char *average_rating = jResp.stringOf("average_rating");
    int rating_count = jResp.IntOf("rating_count");
    int parent_id = jResp.IntOf("parent_id");
    const char *purchase_note = jResp.stringOf("purchase_note");
    int menu_order = jResp.IntOf("menu_order");
    int i = 0;
    int count_i = jResp.SizeOfArray("downloads");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("related_ids");
    while (i < count_i) {
        jResp.put_I(i);
        intVal = jResp.IntOf("related_ids[i]");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("upsell_ids");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("cross_sell_ids");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("categories");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.IntOf("categories[i].id");
        name = jResp.stringOf("categories[i].name");
        slug = jResp.stringOf("categories[i].slug");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("tags");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("images");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.IntOf("images[i].id");
        jResp.DtOf("images[i].date_created",false,date_created);
        jResp.DtOf("images[i].date_created_gmt",false,date_created_gmt);
        jResp.DtOf("images[i].date_modified",false,date_modified);
        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;
    }

    i = 0;
    count_i = jResp.SizeOfArray("attributes");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("default_attributes");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("variations");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("grouped_products");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("meta_data");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("_links.self");
    while (i < count_i) {
        jResp.put_I(i);
        href = jResp.stringOf("_links.self[i].href");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("_links.collection");
    while (i < count_i) {
        jResp.put_I(i);
        href = jResp.stringOf("_links.collection[i].href");
        i = i + 1;
    }



    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

    }

 

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