1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Developer
  5. REST API
  1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. REST API

REST API

You can see the REST route properties by going to the /wp-json/ path of your site. Screenshot example: https://share.getcloudapp.com/Qwudq2YXEndpoint: https://[domain]/wp-json/wc/pewc/[product_id]/

Methods:
GET

no JSON data required
returns {“product_id”:659,”group_order”:”681″}

POST (create group)

accepts JSON Data: {“group_title”:””,”group_description”:””,”group_layout”:””}

all fields are optional, you can pass an empty data and a group will still be created
group_layout must be either ul, table, cols-2, or cols-3, but if blank the default is ul

returns updated group order for the product plus the data of the new group {“group_id”:683,”group_order”:”681,683″,”group_title”:””,”group_description”:””,”group_layout”:””}

Endpoint: https://[domain]/wp-json/wc/pewc/[product_id]/[group_id]/
Methods:
GET (returns group data and all field IDs)

no JSON data required
returns {“group_id”:681,”group_title”:””,”group_description”:””,”group_layout”:””,”field_ids”:[682]}

POST (create field)

accepts JSON Data: {“field_type”:”checkbox”}

accepts any field parameters returned by the function pewc_get_field_params() (see “returns” below to see a list of field parameters)
field_type is required

field_type value is one of the values returned by the function pewc_field_types(), e.g. calculation, checkbox, checkbox_group, etc

returns group_id, field_id, and all AOU field parameters returned by the function pewc_get_field_params()  {“group_id”:681,”field_id”:684,”id”:”pewc_group_681_684″,”field_label”:””,”field_type”:”checkbox”,”field_price”:””,”field_options”:””,”first_field_empty”:””,”field_minchecks”:””,”field_maxchecks”:””,”child_products”:””,”child_categories”:””,”products_layout”:””,”products_quantities”:””,”allow_none”:””,”number_columns”:””,”hide_labels”:””,”allow_multiple”:””,”select_placeholder”:””,”min_products”:””,”max_products”:””,”child_discount”:””,”discount_type”:””,”field_required”:””,”field_flatrate”:””,”field_percentage”:””,”field_minchars”:””,”field_maxchars”:””,”per_character”:””,”show_char_counter”:””,”field_freechars”:””,”field_alphanumeric”:””,”field_alphanumeric_charge”:””,”field_minval”:””,”field_maxval”:””,”multiply”:””,”min_date_today”:””,”field_mindate”:””,”field_maxdate”:””,”offset_days”:””,”weekdays”:””,”blocked_dates”:””,”field_color”:””,”field_width”:””,”field_show”:””,”field_palettes”:””,”field_default”:””,”field_default_hidden”:””,”field_image”:””,”field_description”:””,”condition_action”:””,”condition_match”:””,”condition_field”:””,”condition_rule”:””,”condition_value”:””,”variation_field”:””,”formula”:””,”formula_action”:””,”formula_round”:””,”decimal_places”:””,”field_rows”:””,”multiple_uploads”:””,”max_files”:””,”multiply_price”:””,”hidden_calculation”:””,”price_visibility”:””,”option_price_visibility”:””}

PUT (update group data)

accepts JSON Data: {“group_title”:””,”group_description”:””,”group_layout”:”ul”}

pass at least one of the parameters above
only the parameters passed will be updated

returns updated group data {“group_id”:683,”group_title”:””,”group_description”:””,”group_layout”:”ul”}

DELETE

no JSON data required
returns {“product_id”:659,”group_order”:”681″,”deleted_group_id”:686,”deleted_fields”:[688,687]}

Endpoint: https://[domain]/wp-json/wc/pewc/[product_id]/[group_id]/[field_id]
Methods:
GET (return field data)

no JSON data required
returns group_id, field_id, and all AOU field parameters returned by the function pewc_get_field_params() {“group_id”:681,”field_id”:682,”id”:”pewc_group_681_682″,”field_label”:””,”field_type”:”checkbox”,”field_price”:””,”field_options”:””,”first_field_empty”:””,”field_minchecks”:””,”field_maxchecks”:””,”child_products”:””,”child_categories”:””,”products_layout”:””,”products_quantities”:””,”allow_none”:””,”number_columns”:””,”hide_labels”:””,”allow_multiple”:””,”select_placeholder”:””,”min_products”:””,”max_products”:””,”child_discount”:””,”discount_type”:””,”field_required”:””,”field_flatrate”:””,”field_percentage”:””,”field_minchars”:””,”field_maxchars”:””,”per_character”:””,”show_char_counter”:””,”field_freechars”:””,”field_alphanumeric”:””,”field_alphanumeric_charge”:””,”field_minval”:””,”field_maxval”:””,”multiply”:””,”min_date_today”:””,”field_mindate”:””,”field_maxdate”:””,”offset_days”:””,”weekdays”:””,”blocked_dates”:””,”field_color”:””,”field_width”:””,”field_show”:””,”field_palettes”:””,”field_default”:””,”field_default_hidden”:””,”field_image”:””,”field_description”:””,”condition_action”:””,”condition_match”:””,”condition_field”:””,”condition_rule”:””,”condition_value”:””,”variation_field”:””,”formula”:””,”formula_action”:””,”formula_round”:””,”decimal_places”:””,”field_rows”:””,”multiple_uploads”:””,”max_files”:””,”multiply_price”:””,”hidden_calculation”:””,”price_visibility”:””,”option_price_visibility”:””}

PUT (update field)

accepts JSON Data

pass at least one parameter returned by the function pewc_get_field_params (except id)
only the parameters passed will be updated

returns group_id, field_id, and all AOU field parameters returned by the function pewc_get_field_params()

DELETE

no JSON data required
returns {“product_id”:659,”group_id”:686,”deleted_field_id”:689,”field_ids”:”687,688″}

Sample file: https://gist.github.com/plugin-republic/4a4a1c1a781da3d67917a881e55e6c67

Was this article helpful?

Related Articles