PPOM API Documentation

Enable Rest API 

Make sure REST API is enabled from WooCommerce > Setttings > PPOM Settings > Integrations > REST API.

Endpoint 

Base Endpoint : siteurl/wp-json/ppom/v1/{$operations}

Products - Operations 

1 - Get all PPOM fields attached with product

1.1 Operation  get/product/?product_id=238&secret_key=11122
1.2 Method GET
1.3 Parameters
Key Type Detail
product_id integer mandatory
secret_key string mandatory
1.4 Example Response
{"status": "success",
"message": "Meta found 121",
"meta_id": 121,
"product_id": 238,
"ppom_fields": [{
"title": "My text",
"type": "text",
"data_name": "my_test",
"description": "Just a text input",
"required": 1
}, {
"title": "My text 23",
"type": "text",
"data_name": "my_test3",
"description": "Another text",
"required": 1
}, {
"title": "Type your email",
"type": "email",
"data_name": "your_email",
"description": "Email please",
"required": 1
}, {
"title": "Package",
"type": "checkbox",
"data_name": "package",
"description": "Select Package",
"required": "",
"options": [{
"option": "Basic",
"price": "",
"id": "thebasic"
}, {
"option": "Studend",
"price": "5.20",
"id": "studend"
}, {
"option": "Super",
"price": "7",
"id": "super"
}]
}]
 }
		
Other Status 
success: if operation successful
no_product: if product is not found
no_meta: if no fields/meta attached with product
		

2 - Set/Update PPOM Fields

If requested fields are exists, it will update otherwise add them to product. If no PPOM meta is attached to product then it will create a new meta group with same name as of Product title in WooCommerce and add these fields.

2.1 Operation  set/product/
2.2 Method POST
2.3 Parameters
Key Type Detail
product_id integer mandatory
secret_key string mandatory
fields Array (see section 3.0) (json_encode) mandatory
2.4 Fields Meta
Fields See section 3-Fields Types
Options Extra options for Checkbox,Radio,Select
Property Type
options Array (see section 2.5)
2.5 Example Request
$ppom_fields = array(
 array('title' => 'My text',
 'type' => 'text',
 'data_name' => 'my_test',
 'description' => 'Just a text input',
 'required' => 1),
 array('title' => 'Package',
 'type' => 'checkbox',
 'data_name' => 'package',
 'description' => 'Select Package',
 array(
array('option'=>"Basic",'price'=>'','id'=>'thebasic'),
array('option'=>"Studend",'price'=>'5.20', 'id'=>'student'),
array('option'=>"Super",'price'=>'7', 'id'=>'super'),
 ),
 'required' => 1),
 array('title' => 'Type your email',
 'type' => 'email',
 'data_name' => 'your_email',
 'description' => 'Email please',
 'required' => 1),
 );
		
Actual Post Request
$post_data = array('product_id' => 238,
 'secret_key' => 123123,
 'fields' => json_encode($ppom_fields),
 );
				
2.6 Example Response
 {
"status": "success",
"meta_id": 122,
"product_id": 238,
"fields": [{
"title": "My text",
"type": "text",
"data_name": "my_test",
"description": "Just a text input",
"required": 1
}, {
"title": "Package",
"type": "checkbox",
"data_name": "package",
"description": "Select Package",
"options": [{
"option": "Basic",
"price": "",
 "id": "thebasic"
}, {
"option": "Student",
"price": "5.20",
 "id": "student"
}, {
"option": "Super",
"price": "5%",
 "id": "super"
}],
"required": 1
}, {
"title": "Type your email",
"type": "email",
"data_name": "your_email",
"description": "Email please",
"required": 1
}]
}
		

3 - Delete Fields

3.1 Operation delete/product/
3.2 Method POST
3.3 Parameters
Key Type Detail
product_id integer mandatory
secret_key string mandatory
fields Array (only data_name) mandatory
3.4 Example Request
$delete_fields = array('field_1','field_2');
$post_data = array('product_id' => 238,
 'secret_key' => 123123,
 'fields' => json_encode($delete_fields),
 );
// Delete all fields against product
$delete_fields = array('__all_keys');
		
3.5 Example Response
{
"status": "success",
"meta_id": "123",
"product_id": 238,
"fields": [{
"title": "My text",
"type": "text",
"data_name": "my_test",
"description": "Just a text input",
"required": 1
}, {
"title": "Package",
"type": "checkbox",
"data_name": "package",
"description": "Select Package",
"required": "",
"options": [{
"option": "Basic",
"price": "",
"id": "thebasic"
}, {
"option": "Studend",
"price": "5.20",
"id": "studend"
}, {
"option": "Super",
"price": "7",
"id": "super"
}]
}]
}
		

Order - Operations

1 - Get all meta data information attached with Order

1.1 Operation get/order/?order_id=2141&secret_key=11122
1.2 Method GET
1.3 Parameters
Key Type Detail
order_id integer mandatory
secret_key string mandatory
1.4 Example Response
 {
"status": "success",
"message": "Order found 2141",
"order_items_meta": [{
"product_id": 2028,
"product_meta_data": [{
"id": 3932,
"key": "thehidden",
"value": "22"
}, {
"id": 3933,
"key": "you_compaany",
"value": "nmedia"
}, {
"id": 3934,
"key": "about_compny",
"value": "I love Again"
}, {
"id": 3935,
"key": "email_input",
"value": "najeeb.ahmd82@gmail.com"
}, {
"id": 3936,
"key": "dob",
"value": "28-2-2200"
}, {
"id": 3937,
"key": "gender",
"value": "Male"
}, {
"id": 3938,
"key": "your_date_range",
"value": "22"
}, {
"id": 3939,
"key": "select_timzone",
"value": "22"
}, {
"id": 3940,
"key": "your_interest",
"value": "22"
}, {
"id": 4442,
"key": "package",
"value":
"[{\"option\":\"Basic2\",\"price\":\"\",\"id\":\"basic2\"},{\"opt
ion\":\"Studend\",\"price\":\"5.20\",\"id\":\"studend\"}]"
}, {
"id": 3942,
"key": "colors_palettes",
"value": "22"
}, {
"id": 3943,
"key": "select_image",
"value": "22"
}, {
"id": 3951,
"key": "your_age",
"value": "22"
}]
}]
}
		
Other Status 
success: if operation successful
no_order: if order is not found
		
Checkbox/Radio/Select value Checkbox/radio/select type input values will be shown as encode array (string output) in which each option will have following keys:
option
price
id
		

2 - Set/Update Meta/Fields against order

If requested fields are exists, it will update otherwise add them to order.

Return: All meta fields attached to order

2.1 Operation set/order/
2.2 Method POST
2.3 Parameters
Key Type Detail
order_id integer mandatory
secret_key string mandatory
fields Array (see section 2.4)(json_encode)
Example:
{product_id:{ppom_field_1:new_value_1, ppom_field_2:new_value_2}}
mandatory
2.4 Example Request
// checkbox,radio or select will be sent as collection of arrays like
below:
$cb_options[] = array('id'=>'studen_id','option'=>'Students
Data','price'=>'7.2');
$cb_options[] = array('id'=>'suject','option'=>'Social Studies');
$ppom_fields = array(
 2028 => array(
 'about_compny'=>'I love Again',
 'email_input'=>'najeeb.ahmd82@gmail.com',
 'your_age'=>36,
 'package'=> $cb_options,
),
 );
$post_data = array('product_id' => 238,
 'secret_key' => 123123,
 'fields' => json_encode($ppom_fields),
 );
In above example $ppom_fields has key as item id in order with array is
given with data_name=>value pair.
		
2.5 Example Response
 Same as in 1.4 in Orders
		

3 - Delete Meta/Fields in Order

Return: All meta fields attached to order

2.1 Operation delete/order/
2.2 Method POST
2.3 Parameters
Key Type Detail
order_id integer mandatory
secret_key string mandatory
fields Array (see section 2.4) (json_encode) mandatory
2.4 Example Request
$delete_fields = array(
 2028 => array('your_email', 'select_image'),
 );
$post_data = array('product_id' => 238,
 'secret_key' => 123123,
 'fields' => json_encode($delete_fields),
 );
In above example $delete_fields has key as item id in order with
array is given with data_name=>value pair.
		
Same as in 1.4 in Orders
		

3 - Field Types Table

Field type data_name title description required options
Text text unique ANY ANY true:1,false: 0 N/A
Email email unique ANY ANY true:1,false: 0 N/A
Date date unique ANY ANY true:1,false: 0 N/A
Number number unique ANY ANY true:1,false: 0 N/A
Textarea textarea unique ANY ANY true:1,false: 0 N/A
Date Range daterange unique ANY ANY true:1,false: 0 N/A
Timezone timezone unique ANY ANY true:1,false: 0 N/A
Color Picker color unique ANY ANY true:1,false: 0 N/A
Select select unique ANY ANY true:1,false: 0 See section 3.1
Radio radio unique ANY ANY true:1,false: 0 See section 3.1
Checkbox checkbox unique ANY ANY true:1,false: 0 See section 3.1

3.1 - Options

Options is an array with following keys:

'options' => array(
 array('option'=>"Basic",'price'=>''),
 array('option'=>"Student",'price'=>'5.20'),
 array('option'=>"Super",'price'=>'5%'),
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us