For some reason, you have to double the arrays, maybe this doesn’t affect you as you are referencing the firt element. I use this in PHP:
function saveMetaItem($id_order,$id_item,$id_product,$meta_key,$meta_value){
$woo = new wooclient();
$data = array(
'line_items' => array(array(
'id' => $id_item,
'product_id' => $id_product,
'meta_data' => array(array(
'key' => $meta_key,
'value' => $meta_value
))
))
);
$result = $woo->put('orders/'.$id_order, $data);
return $result;
}
Notice the double array() calls in both line_items and meta_data. Also provide both id and product_id. Convert that to JSON and your done 😉
Related Posts:
- Cant create or update meta fields using WordPress REST API
- WP-API + JS Backbone client – how to update post meta
- How to update/insert custom field(post meta) data with wordpress REST API?
- WP REST API “rest_no_route” when trying to update meta
- Options to get my custom post type metadata via the WordPress API
- Is it possible to update a post meta field through REST API if the format of it when registered is nested?
- Mass importing json data into custom fields (postmeta)
- Unknown characters added to meta data values
- How to properly use oneOf and anyOf in Rest Schema?
- Bulk Update Post Meta Values from Different Post via Rest Api
- How to register post meta with multi level arrays?
- How to add a post’s view count into the WordPress API response
- Attachment metadata has value of ‘1’
- Best Way to detect unique posts in wp rest api
- WP-API : post_meta not updated… but have another entry
- Hiding WordPress REST API v2 endpoints from public viewing
- How can I get the post ID from a WP_Query loop?
- How to edit a post meta data in a Gutenberg Block?
- How to loop through JSON data in wordpress WP REST API
- How to update/delete array in post meta value?
- WP REST API V2 – Modifying responses
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- How to store post meta in an array?
- adding a URL to a post meta
- update_post_meta() not working when used with WordPress action
- Adding meta data to an attachment post
- wordpress custom endpoint multiple params
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Problem With Order Item Meta In Woocommerce
- Job of meta_key meta_value fields in database tables
- How to retrieve custom meta term of category taxonomy from WP Rest API?
- Gutenberg Custom Block Getting All Posts
- Best way to save postmeta
- How to add meta data to WordPress posts?
- How to update Post Meta values through the comment system
- Filtering multiple meta_values
- How to add WP API and JS featured image attachment
- How add post_meta from user_meta?
- How can I get my iFrame to work with url from post_meta?
- How to use update_post_meta() function properly?
- Update post meta in woocommerce order frontend
- populate post meta in gravity forms [closed]
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- post meta parameter in post custom-post-type endpoint with restapi
- How to receive all the meta information of a post ?
- Add Data to Response of WP-JSON Root
- Compare old meta with new post meta
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- Read post meta values, only if posts are public
- Time & Date on Post – Time Ago Custom Function
- Updating my Post when expiry date is past
- Mass removing CSS from 1,700 post [closed]
- Help with Post Meta
- How do I manage custom meta in post revisions in the Block Editor era?
- Generate metadata for cloud images
- Migrating meta value to new meta value
- Insert multiple metas in one time
- How to extract data from a post meta
- WP REST API and Access-Control-Allow-Origin
- count post meta values
- Correct meta of Writing Meta Tags
- Get post_meta from specific post [closed]
- How to add tags to post from frontend?
- Retrieve user_meta and copy to post_meta
- getting the post_id from the post_meta
- troubles with get_post_meta (and saving it)
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- WordPress REST API – get custom taxonomy category posts
- How to merge the array values in foreach?
- How to exclude posts by meta key value in the_post_navigation next prev links?
- Remove unwanted fields from WP API response
- update_post_meta not working with transition_comment_status
- WordPress API “code”:”rest_no_route” with Custom Route
- Update post meta date always store 1970-01-07
- Is it possible to pass an whole array using custom field in wordpress?
- How do I update a specific value within array in a products metadata?
- Optimize WP Meta Query for large amount of post meta?
- rendering open graph meta tags in wordpress
- Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable
- Restore deleted _thumbnail_id in postmeta table
- Hide the_meta if no value
- php wp_insert data on front using a form
- Updating post_meta when updating a setting with the Settings API
- How to show specific meta keys of all posts in admin panel?
- wp_schedule_event not working
- Media library orphans
- WordPress join posts with meta values of array type
- How to make certain content of the post noindex and no follow. not entire post?
- Export posts with postmeta without ID?
- How can I display my meta value in a textarea? [closed]
- delete blank space in post_meta empty [closed]
- Auto save title as custom meta field value
- API request forbidden when requesting from same domain
- How to show wordpress post in the site based on custom field value?
- How can I enforce user to use Application password to generate JWT token? [closed]
- Extend file format support for post thumbnails
- Why isn’t my embed_video WYSIWYG field updating when using update_post_meta?
- rest_api_init is not getting invoked inside a Class