1. Home
  2. General
  3. FAQ

How does the plugin work with the REST API?

The WordPress REST API provides a way to interact with your website by JSON objects. We ensure our plugins work with REST wherever possible.

This article contains details about how specific plugins work with the REST API.

Document Library Pro

By default, your Document Library Pro documents are not shown in REST. If you want to add support for REST API, you can use this code:

add_filter('register_post_type_args', function( $args, $post_type ) { 
if ($post_type == 'dlp_document'){ 
$args['show_in_rest'] = true; 
} 
return $args; 
}, 10, 2);

After this, another endpoint will be added to the wp/v2 namespace and you can access the documents like this:

wp-json/wp/v2/book/

Easy Post Types and Fields

By default, the post types that you create with the Easy Post Types plugin won’t show in REST. If you want to add them to REST, you can read this article and add the REST support via code.

Password Protected Categories, WooCommerce Protected Categories and WooCommerce Private Store

If you’re using our Password Protected Categories, WooCommerce Protected Categories or WooCommerce Private Store plugins and your products or posts are protected, then it’s still possible to access them via the REST API. Our plugins use cookies to set protection for the content and these cookies don’t work while accessing the content with REST.

Posts Table Pro and WooCommerce Product Table

Posts Table Pro and WooCommerce Product Table don’t create new database tables for storing your data, and instead use the existing ones in WordPress. Therefore, you can easily access them by using the product and post routes.

WooCommerce Lead Time

Our lead time plugin adds some custom fields to the products. All of these fields are accessible via the REST API.

For example, if you want to get the lead time for a product, you can retrieve that product and look for the _wclt_lead_time key in the 'meta_data' of the JSON response.

WooCommerce Product Filters

WooCommerce Product Filters has its own route to handle the filters and options. This is for internal use only and it’s not recommended to use it outside of the plugin.

WooCommerce Product Options

WooCommerce Product Options uses the REST API to modify the product options and groups. There are 3 routes under the wc-product-options/v1 namespace that you can use:

file-upload:

This is used to upload files for the 'File Upload' filter type on the front end. You can pass these two parameters to this route in a 'POST' request:

  • option_id (int)
  • file (binary)

groups:

You can retrieve, create, update, delete, reorder, or duplicate the groups. For more information about the parameters and the requests, see the src/Rest/Routes/Group.php file.

options:

You can retrieve, create, delete, update, or reorder the options. For more information about the parameters and the requests, see the src/Rest/Routes/Option.php file.

WooCommerce Wholesale Pro

Our wholesale plugin adds some custom fields to the products. All of these fields are accessible via the REST API.

For example, if you want to get the wholesale price for a product, you can retrieve that product and look for the price in the 'meta_data' of the JSON response. Remember that the meta key changes based on the user role and type of the price.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.