WooCommerce API - Update Order Meta Fields

woocommerce rest api
woocommerce rest api get all products
wordpress rest api update post meta
update order meta woocommerce
woocommerce oauth
woocommerce rest api get products by category
woocommerce wishlist rest api

Does the WooCommerce Rest API offer any way to update meta fields?

They have an Extension which adds the ability to add tracking numbers to an order when it's shipped using meta fields, but don't have any documentation on how or if it's possible to update the order's meta fields with this information via their REST API.

2020 Update:

The latest versions of the WooCommerce API allow updating meta fields that start with an underscore. Yay! You can do so in bulk as big_water mentioned below: https://stackoverflow.com/a/44661445/137695

You can also update meta fields for a single order using the new V2 or V3 WooCommerce API Order Update PUT endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-order

"meta_data": [
    "key": "_some_field",
    "value": "some value"
    "key": "_some_other_field",
    "value": "some other value"

OLD ANSWER BELOW - Regarding the old WooCommerce API endpoints only:

It's poorly (read not at all) documented how to do this. Here's how to do it for normal meta fields:

curl -X PUT "https://somesite.com/wc-api/v2/orders/124?filter[meta]=true" -u ck_yourconsumerkey:cs_yourconsumersecret -H "Content-Type: application/json" -d 
    "order": {
        "order_meta": {"meta_key":"meta_value"}

Meta fields that start with an underscore are protected and cannot be updated via the API. However, according to this GitHub issue the next version of WooCommerce should support updating protected meta fields as long as they aren't WooCommerce internal values.

There are Meta fields for other parts of the order like customer and item, but it would take me a while to dig up info on those again and this question was specifically regarding Order level meta fields.

Edit: WooCommerce has changed their minds and closed the GitHub case saying they will not allow access to these fields. This unfortunately makes WooCommerce one of the only shopping carts where it is impossible to add tracking information to an order via the API without a terrible hackish workaround.

Update Line Item Meta Data - WooCommerce API, stuck trying to update line item meta fields I've attached to each line item. /wp- json/wc/v2/orders/2594/line_items function saveMetaItem($id_order,$id_item,$ id_product,$meta_key,$meta_value){ $woo = new wooclient(); $data = array( Notice the double array() calls in both line_items and meta_data. woocommerce_form_field; woocommerce_format_decimal; woocommerce_format_hex; WooCommerce Order Item Meta API - Update term meta. Package: WooCommerce\Functions

Yes it is possible. Using the REST API for Woocommerce version 3.0, I added custom order tracking and carrier fields using the following json on the endpoint described in their latest documentation here.

    "update": [
            "id": 77248,
            "status": "shipping",
                    "key": "package_carrier",
                    "value": "USPS First Class"
                    "key": "tracking_number",
                    "value": "12354LKJSDF"

They then show on the order edit screen:

This is obviously using the batch update for order, however, this should still work for the single orders endpoint as well.

Since I'm not including an "id" field, it creates a new one. I believe to update the fields, you need to supply the "id" field.

WooCommerce REST API Documentation, Custom Meta to order from cart � What is the correct way to update meta fields in to generate API requests based on Woocommerce checkout data in order to� When an order is placed in WooCommerce, you might want to change/add something in the User Meta programmatically. For example, you could “check” a custom checkbox in the User Profile. Or maybe assign the User Twitter username. And so on 🙂 PHP Snippet: Update User Meta After a Successful Order in WooCommerce Related posts: WooCommerce: […]

You can use a HTTP POST request to the "/wp-json/wc/v3/orders" endpoint with the extra "meta_data" field as shown in the following curl command. This is tested using the "REST API for Woocommerce version 3.0"

curl --request POST \
     --url https://yourserver.com/wp-json/wc/v3/orders \
     --header 'authorization: Basic <credentials>' \
     --header 'content-type: application/json' \
     --data '{
    "line_items": [
      "product_id": 425,
      "quantity": 1
            "key": "custom key",
            "value": "custom value"

Is there any way we can update the order meta of WooCommerce , Custom order statues are supported in addition to the default pending curl https ://www.skyverge.com/wc-api/v1/orders?fields=id,status� Addition of WooCommerce Custom Checkout Field. The following code will add a field to the checkout page, saves the data to the order meta, and displays the order meta in the orders admin.

WooCommerce REST API: Get and Update Order Information , Update order item meta through REST API #10846. Closed Is there a way to update a meta field at the line level? Thanks so much! woocommerce locked and limited conversation to collaborators on Oct 30, 2017. You can update the status of an order using the PUT /orders/# {id} endpoint. All actions that are triggered normally when changing the status of an order in the admin (e.g. sending emails, granting download permissions) are also triggered when changing the order status via the API.

Update order item meta through REST API � Issue #10846 , This is a WC REST API limitaion, not much we can do. meta_data is not listed in the WooCommerce REST API docs, but you can give it a try. Managed to update my field by editing the Woocommerce API code, and run update_post_meta with $request ['meta_data'] when using parms = { "meta_data", "whatever" } However, the field is only a string now, not an array as the API would like it to be in order to be able to update the values.

Update order custom field � Issue #73 � XiaoFaye/WooCommerce , [This thread is closed.] I tried successfully to add a custom field to my test WP installation; the filed also appears using woocommerce REST API:… But the always result is the same, I can't access to field meta_data. WooCommerce REST API: updating order line item metadata for shipment. 1.

  • Thanks @big_water ! Just tested, if you don’t provide the id, a new meta data will be created with a new id, while the old meta data with the same key will be deleted.