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
- Get posts by meta value with date
- 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
- need to add add user names to the post for later retrieval or removal
- Trying to get property of non-object error using get_post_meta()
- Like & Dislike functionality using JavaScript
- rest_no_route on custom API endpoint wordpress
- update_post_meta not working in plugin
- get_permalink vs the_permalink
- Updating my Post when expiry date is past
- How to remove Date from Meta Description on SERP?
- How to display sql query fired by posts_where
- Unfiltered html with update_post_meta
- get meta value from page query
- why after saving meta value it’s saving all the values the one that i clicked?
- How is the author’s name given a different color?
- WordPress REST Api get posts by ID
- How to use Python to create a Post in WordPress?
- update_callback is not working in register_rest_field
- How does WordPress treats attachments metadata in post content?
- get_post_meta in one post only
- Displaying the ‘time ago’ for recent activity within a post/custom post type?
- add post meta front end edit
- How to query and update one colum in postmeta table?
- How to remove date from showing in meta description
- How to make an API call to a custom post type but filtering by meta value?
- How to save HTML data into SQL post_content column
- update post meta value with other post meta value
- Check For get_post_meta on Author Archive Page
- Negative meta_query if storing multiple post_meta values with shared meta_key
- Check if user can in javascript
- How can I update this array built from post meta data?
- What format is this and how to get value “lal” and “pila” from it
- Frontend query and does not need to log in [closed]
- Get data from custom table and update relative post_meta based on meta_key
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
- Adding Amchart Interface to WordPress API
- Deleting media using the WordPress Rest API
- Programatically delete several attributes in _product_attributes in post meta
- Get post meta after insert post
- Data not displaying in text field
- How do you sort the items in a custom taxonomy meta box?
- Proper Way to Sanitize Meta Input
- update_post_meta returning false when called during init
- When importing posts to a new site if XML file has postmeta not setup on new server what happens?
- Access Serialized Post Meta Values
- Cache metadata for set of posts
- Problem with get_post_meta
- External api call using wordpress
- Woocommerce API for calling products by Category ID
- wordpress rest api authentication failed