Search code examples
woocommercepostmanwordpress-rest-apiwoocommerce-rest-api

how update woocommerce product meta_data with postman


how update woocommerce product meta_data with postman

please help update

{
    "id": 15841,
    "name": "LCD IPHONE 8G WHITE ORG CHIN",
    "slug": "lcd-iphone-8g-white-org-chin",
    "status": "publish",
    "meta_data": [
        {
            "id": 452463,
            "key": "_erp_code",
            "value": "bBALOw92agF4QB4O"
        },
        {
            "id": 464050,
            "key": "_wp_old_date",
            "value": "2022-05-12"
        },
        {
            "id": 464051,
            "key": "_holo_sku",
            "value": "0118657"
        },
        {
            "id": 464052,
            "key": "_ipeir_woo_products_tabs",
            "value": []
        }
    ]
}

only update _holo_sku value

pust method in postman


Solution

  • This is well documented in the WooCommerce REST API docs. Search in Products > Update a product section (click here).

    You need a PUT request to the products endpoint URL (replace your product ID):

    /wp-json/wc/v3/products/<id>
    

    Your $data should only contain the meta_data (only key and value, since id is redundant):

    "meta_data": [
        {
            "key": "_holo_sku",
            "value": "0118657"
        },
    ]
    

    WC REST API is fully integrated in Postman natively, so this should be pretty easy and straightforward.