1. Home
  2. Knowledge Base
  3. General
  4. 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. User or role protected categories can be accessed via the REST API so long as the correct authentication is used. Password protected categories will be protected in the REST API but cannot be unlocked as this can only be done via the password form on the front end of your site.

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 Discount Manager

WooCommerce Discount Manager uses the REST API to handle management of discounts, retrieval of products and users.

Routes can be found under the wdm/v1 namespace.

discounts

Submitting a GET request to this route will return a list of all discounts.

Submitting a DELETE request to this route allows you delete the given discount. The request accepts one parameter, id - the ID of the discount to delete.

discounts/duplicate

Submitting a POST request to this route will duplicate the given discount.

The route accepts one parameter:

  • discount_id: The ID of the discount to duplicate.

discounts/toggle

Submitting a POST request to this route will toggle the status of the specified discount.

The route accepts the following parameters:

  • discount: The ID of the discount to toggle.
  • enabled: The status of the discount. true for enabled, false for disabled.
    discounts/products

Submitting a GET request to this route will return a list of all products in the database.

discounts/users

Submitting a GET request to this route will return a list of a users.

The route accepts the following parameters:

  • search: String used to search for specific users by username, display name, email, first and last name.
  • include: Comma separated string of users that must be included in the results.

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 uses the REST API to handle pricing functionality of filters, terms and batch indexing. There are 4 routes under the wcf/v1 namespace that you can use:

start-batch-index

Submitting a POST request to this route starts the batch indexing process for all products. This request does not accept any parameters.

indexer-status

Checks the status of the batch indexing process. Submitting a GET request will return an array containing the following properties:

success

Whether or not the request was successful.

running

Whether or not the indexing process is still running.

pricing

Gets the maximum pricing for a given taxonomy term via a POST request. This is used internally and should not be used for public facing requests.

The request accepts the following parameters:

  • term_id: The term ID for which we're making the request.
  • taxonomy: The taxonomy where the term belongs to.
    terms

Retrieve the list of terms for a given taxonomy via a GET request.

The request accepts the following parameters:

  • taxonomy: The taxonomy for which we want to retrieve the terms.
  • search: String used to search for terms within the specified taxonomy.
  • include: Comma separated string of term ids that must be included in the request.

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.