Home › Forums › WooCommerce Personalized Product Options Manager (PPOM) › REST API fields
- This topic has 12 replies, 3 voices, and was last updated 5 years, 7 months ago by Jane Brian.
-
AuthorPosts
-
June 20, 2018 at 11:27 am #8997DanielParticipant
In case I want to use the wordpress rest api functionality, how the PPOM fields will be returned?
Thanks
June 20, 2018 at 3:00 pm #8999nmediaKeymasterHi,
Please see PPOM API Guide provided with plugin package/zip.
July 9, 2018 at 10:09 am #9092DanielParticipantHello again,
I am trying to add an extra field to an existing order with rest api:POST server_url/wp-json/ppom/v1/set/order/?order_id=14&secret_key=secret&fields=[{“id”:”rosaroja”}]
But I am not seeing any difference when I get the fields from the order with:
GET server_url/wp-json/ppom/v1/get/order/?order_id=14&secret_key=secret
Could you show me how to do it correctly?
Will the POST set/order update the order price aswell?
Thank you in advance
July 9, 2018 at 4:02 pm #9093nmediaKeymasterHi,
in fields, you are not sending params in required way, please see API Document. Here is example to add key inside order against item/product id 2209
fields={"2209": {"mytextchange": "My Text"}}
July 11, 2018 at 9:32 am #9098DanielParticipantHi!
I am sorry but I don’t understand what it is this 2209 and which information is “mytextchange”.In my case I have a user ordering an order (order_id=14) of a product (product_id=9) and added one extra option.
I created the basic order with WooCommerce REST API: POST server_url/wp-json/wc/v2/ordersAnd now want to add the PPOM extra field:
POST server_url/wp-json/ppom/v1/set/order/?order_id=14&secret_key=secret&fields=[{“9”:{????]
If my options are (using GET server_url/wp-json/ppom/v1/get/product/?product_id=9&secret_key=secret):
{
“status”: “success”,
“message”: “Meta found 1”,
“meta_id”: 1,
“product_id”: 9,
“ppom_fields”: [
{
“title”: “Fields title 1”,
“type”: “quantities”,
“data_name”: “Fields name 1”,
“description”: “Opcions to add”,
“required”: “”,
“options”: [
{
“option”: “Option 1”,
“price”: “1,20”,
“min”: “0”,
“max”: “”,
“id”: “option1”
}]
}]
}What shall I add on the “????” of the Rest API request?
Thank you in advance!
July 11, 2018 at 3:01 pm #9100nmediaKeymasterHi,
can you please open API Document guide included in PRO pack and see section 2.4. An example is given to update order with option and it’s value like (title, price)
July 20, 2018 at 11:43 am #9121DanielParticipantHi,
thank you for the reply. I did read the API guide, unfortunately the example is in PHP, and I am using Postman to test the endpoints to later use it on an Android application and isn’t clear for me.I have some questions about the documentation example:
1- What is it the “2209” ? The product id?
2- How and which options information shall I send in the “fields” parameters on the request URL?
3- Using this endpoint will automatically add the price to the order price or I have to do it manually?Thank you in advance 🙂
July 21, 2018 at 12:35 pm #9127nmediaKeymasterHi,
here is sample request via POSTMAN to your site endpoint:
https://YOURDOMAIN.COM/wp-json/ppom/v1/set/product?product_id=2209&secret_key=11122&fields=[{ "type": "text", "title": "My text", "data_name": "mytext" }, { "type": "select", "title": "Select order", "data_name": "select order", "options": [{ "option": "Asc", "price": 3 }, { "option": "Desc", "price": 4 }], "selected":"Asc" } ]
July 24, 2018 at 5:55 am #9132DanielParticipantThank you for the example, but I am afraid the original question was how to add a extra field in an ORDER.
We tried, something like this:
POST server_url/wp-json/ppom/v1/set/order/?order_id=14&secret_key=secret&fields={“9”:{[
{
“option”: “Option 1”,
“price”: “1,20”,
“id”: “option1”
}]]}Where id_product=9 and id_order=14.
The endpoint doesn’t give an error, but doesn’t add the fields neither.
Should the id_product (9 in my example) be the line item id of the order?
Using this endpoint will automatically add the price to the order price or we have to do it manually?A sample request might be really helpful.
Thank you!
July 28, 2018 at 2:11 pm #9140nmediaKeymasterok here is example script with POSTMAN to add meta options in order
https://YOURDOMAIN.COM/wp-json/ppom/v1/set/order?order_id=2248&secret_key=11122&fields={ "2209": { "mytextchange": "co not", "business": [{ "option": "CEO", "id": "title", "price": 99 }, { "option": "Salary", "id": "salary", "price": 99 }] } }
August 6, 2018 at 10:15 am #9160DanielParticipantHi there!
Thank you for the example, but still doesn’t work with my data.Could you please define what is it the “2209”, “mytextchange” and “business” from the example?
Thank you!
August 10, 2018 at 1:49 pm #9178nmediaKeymaster2200 = Product
mytextchagne = is field with value ‘co not’
business = is another field BUT with priceApril 25, 2019 at 1:53 pm #11787Jane BrianKeymasterHI
It has been a long while for this topic, so we are closing this. -
AuthorPosts
- The topic ‘REST API fields’ is closed to new replies.