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

Unicode C++ 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
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

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
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
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

 

 

 

(Unicode C++) 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++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
#include <CkDtObjW.h>

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

    CkHttpW 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(L"consumer_key");
    http.put_Password(L"consumer_secret");

    CkHttpResponseW *resp = http.QuickRequest(L"DELETE",L"https://example.com/wp-json/wc/v3/products/794?force=true");
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponseBody;
    resp->GetBodySb(sbResponseBody);
    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = resp->get_StatusCode();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",resp->header());
        wprintf(L"Failed.\n");
        delete resp;
        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.

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

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

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

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

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

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

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

    i = 0;
    count_i = jResp.SizeOfArray(L"images");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.IntOf(L"images[i].id");
        jResp.DtOf(L"images[i].date_created",false,date_created);
        jResp.DtOf(L"images[i].date_created_gmt",false,date_created_gmt);
        jResp.DtOf(L"images[i].date_modified",false,date_modified);
        jResp.DtOf(L"images[i].date_modified_gmt",false,date_modified_gmt);
        src = jResp.stringOf(L"images[i].src");
        name = jResp.stringOf(L"images[i].name");
        alt = jResp.stringOf(L"images[i].alt");
        i = i + 1;
    }

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

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

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

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

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

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

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

 

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