meta_data on order creation (Rest API)
-
I am working with the rest api (v3) and ionic. I am trying to create an order (which works fine) but along with that order I am trying to add meta_data. I can see the meta_data in rest with orders that have been submitted though wordpress. When I submit the order I am getting the following error:
data: {status: 400, params: {meta_data: “meta_data is not of type array.”}}
message: “Invalid parameter(s): meta_data”Here is a code snippet:
data = {
payment_details : {
method_id: paymentData.method_id,
method_title: paymentData.method_title,
paid: true
},
billing: this.newOrder.billing,
shipping: this.newOrder.shipping,
line_items: orderItems,
meta_data: {
“vets_name”: this.newOrder.meta_data.vets_name,
“vets_city”: this.newOrder.meta_data.vets_city,
“vets_state”: this.newOrder.meta_data.vets_state,
“vets_phone”: this.newOrder.meta_data.vets_phone,
}Without the meta_data, the order is created without a problem.
Thanks!
-
It appears that you are using the WooCommerce API, which is similar but different from the WP API. If so, I suggest you ask in the WooCommerce dedicated support forum where its devs and expert users can help you.
IDK if this translates to the WC API, but in WP we must register our meta data before it can be used in the API. See https://developer.ww.wp.xz.cn/rest-api/extending-the-rest-api/modifying-responses/
ah geez, I did post in in the wrong forum. Sorry. Thanks for the answer. BTW, the meta data is registered to use rest
No worries about which forum. We know it’s not always easy to decide upon the right place. I hope you will find a solution soon.
The topic ‘meta_data on order creation (Rest API)’ is closed to new replies.