WooCommerce Wholesale Prices Premium REST API Documentation

WooCommerce Wholesale Prices Premium REST API Documentation

As of version 1.18, WooCommerce Wholesale Prices Premium (WWPP) introduces integration with WooCommerce API. This allows Wholesale Products to be created, read, updated, and deleted using WordPress REST API Authentication methods and standard HTTP verbs which are understood by most HTTP clients. The current WP REST API integration version is v3.
Getting Started
In this article, we won』t cover how to access or use the endpoints. It』s up to you to decide which method you will use to access the data. But in our examples, we use JSON to show how the data can be sent and received. To learn more about WooCommerce REST API, please check the following sources:

Learn how to set up your WooCommerce API key here: https://docs.woocommerce.com/document/woocommerce-rest-api/
Learn how to use WooCommerce REST API with PHP here: https://packagist.org/packages/automattic/woocommerce
Learn how to use WooCommerce REST API with Postman here: https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API
Learn more about WooCommerce REST API here: https://woocommerce.github.io/woocommerce-rest-api-docs/

Wholesale Data Properties In API』s Response
WWPP API introduces a new wholesale_data property in the response to group all wholesale data. This property contains:

Attribute
Type
Description
Available On

wholesale_price
array
The Wholesale Prices set on the backend
Simple, Variation

variable_level_wholesale_minimum_order_quantity
array
The Parent Product Wholesale Minimum Order Quantity
Variable

wholesale_minimum_order_quantity
array
The Wholesale Minimum Order Quantity
Simple, Variation

variable_level_wholesale_order_quantity_step
array
The Parent Product Wholesale Order Quantity Step
Variable

wholesale_order_quantity_step
array
The Wholesale Order Quantity Step
Simple, Variation

wwpp_product_wholesale_visibility_filter
array
The Restrict To Wholesale Roles for Simple and Variable, the Wholesale Exclusive Variation for Variation
Simple, Variable, Variation

wwpp_ignore_cat_level_wholesale_discount
string
The Disregard Product Category Level Wholesale Discount option
Simple, Variable

wwpp_ignore_role_level_wholesale_discount
string
The Disregard Wholesale Role Level Wholesale Discount option
Simple, Variable

wwpp_enable_quantity_discount_rule
string
The Enable further wholesale pricing discounts based on quantity purchased? option
Simple, Variable, Variation

wwpp_quantity_discount_rule_mapping
array
The Product Quantity Based Wholesale Pricing rules
Simple, Variable, Variation

wholesale_price
The wholesale_price property contains the wholesale price set on the backend/product editor, not the calculated wholesale price. The response is formatted like this:
"wholesale_price": {
"": ""
}
Example of the response:
"wholesale_price": {
"gold_role": "50",
"wholesale_customer": "100"
}
variable_level_wholesale_minimum_order_quantity
The variable_level_wholesale_minimum_order_quantity property contains the Parent Product Wholesale Minimum Order Quantity set on the backend/product editor. Please note that this option only available for the Variable (parent) products. The response is formatted like this:
"variable_level_wholesale_minimum_order_quantity": {
"": ""
}
Example of the response:
"variable_level_wholesale_minimum_order_quantity": {
"gold_role": "5",
"wholesale_customer": "10"
}
wholesale_minimum_order_quantity
The wholesale_minimum_order_quantity property contains the Wholesale Minimum Order Quantity set on the backend/product editor. It』s the same as variable_level_wholesale_minimum_order_quantity, but for Simple Products and Variations. The response is formatted like this:
"wholesale_minimum_order_quantity": {
"": ""
}
Example of the response:
"wholesale_minimum_order_quantity": {
"gold_role": "5",
"wholesale_customer": "10"
}
variable_level_wholesale_order_quantity_step
The variable_level_wholesale_order_quantity_step property contains the Parent Product Wholesale Order Quantity Step set on the backend/product editor. Please note that this option only available for the Variable (parent) products. The response is formatted like this:
"variable_level_wholesale_order_quantity_step": {
"": ""
}
Example of the response:
"variable_level_wholesale_order_quantity_step": {
"gold_role": "2",
"wholesale_customer": "3"
}
wholesale_order_quantity_step
The wholesale_order_quantity_step property contains the Wholesale Order Quantity Step set on the backend/product editor. It』s the same as variable_level_wholesale_order_quantity_step, but for Simple Products and Variations. The response is formatted like this:
"wholesale_order_quantity_step": {
"": ""
}
Example of the response:
"wholesale_order_quantity_step": {
"gold_role": "2",
"wholesale_customer": "3"
}
wwpp_product_wholesale_visibility_filter
The wwpp_product_wholesale_visibility_filter property contains the value of Restrict To Wholesale Roles option for Simple and Variable (parent) products, and Wholesale Exclusive Variation option for Variation. The response is formatted like this:
"wwpp_product_wholesale_visibility_filter": [""]
Example of the response:
"wwpp_product_wholesale_visibility_filter": ["wholesale_customer","gold_role"]
wwpp_ignore_cat_level_wholesale_discount
The wwpp_ignore_cat_level_wholesale_discount property contains the value of Disregard Product Category Level Wholesale Discount option under the Wholesale Pricing Options section. The value is 「yes」 or 「no」. Example of the response:
"wwpp_ignore_cat_level_wholesale_discount": "yes"
wwpp_ignore_role_level_wholesale_discount
The wwpp_ignore_role_level_wholesale_discount property contains the value of Disregard Wholesale Role Level Wholesale Discount option under the Wholesale Pricing Options section. The value is 「yes」 or 「no」. Example of the response:
"wwpp_ignore_role_level_wholesale_discount": "yes"
wwpp_enable_quantity_discount_rule
The wwpp_enable_quantity_discount_rule property contains the value of Enable further wholesale pricing discounts based on quantity purchased? under the Product Quantity Based Wholesale Pricing section. The value is 「yes」 or 「no」. Example of the response:
"wwpp_enable_quantity_discount_rule": "yes"
wwpp_quantity_discount_rule_mapping
The wwpp_quantity_discount_rule_mapping property contains the rules of Product Quantity Based Wholesale Pricing. The response is formatted like this:
"wwpp_quantity_discount_rule_mapping": [
{
"wholesale_role": "",
"start_qty": "",
"end_qty": "",
"price_type": "",
"wholesale_price": ""
}
]
Example of the response:
"wwpp_quantity_discount_rule_mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "10",
"end_qty": "15",
"price_type": "fixed-price",
"wholesale_price": "50"
},
{
"wholesale_role": "gold_role",
"start_qty": "5",
"end_qty": "",
"price_type": "percent-price",
"wholesale_price": "20"
}
]
Wholesale Data Parameters In API Request
WWPP API allows you to provide some parameters to set the wholesale data of a product. The parameters you can use are:

Parameters
Type
Description
Available For

wholesale_price
array
The Wholesale Prices set on the backend
Simple, Variation

wholesale_minimum_order_quantity
array
The Wholesale Minimum Order Quantity
Simple, Variable, Variation

wholesale_order_quantity_step
array
The Wholesale Order Quantity Step
Simple, Variable, Variation

wholesale_visibility_filter
array
The Restrict To Wholesale Roles for Simple and Variable, the Wholesale Exclusive Variation for Variation
Simple, Variable, Variation

ignore_cat_level_wholesale_discount
string
The Disregard Product Category Level Wholesale Discount option
Simple, Variable

ignore_role_level_wholesale_discount
string
The Disregard Wholesale Role Level Wholesale Discount option
Simple, Variable

wholesale_quantity_discount_rule_mapping
array
The Product Quantity Based Wholesale Pricing rules
Simple, Variable, Variation

wholesale_price
The wholesale_price parameter is used to set the wholesale prices. The wholesale price value should be an integer.
The parameter data is formatted like this:
"wholesale_price": {
"":
}
Example of the request:
"wholesale_price": {
"gold_role": 50,
"wholesale_customer": 100
}
The current behavior of this parameter:1. If you provide empty string for the _wholesale_price_ parameter, it will be ignored as if you don』t set _wholesale_price_ parameter at all.2. If you provide non-wholesale role keys (regular customer or non-existing roles), it will be ignored. It will only input wholesale price with a valid wholesale role.3. If you provide string or empty string value as the wholesale price, it will be ignored. It will only input integer wholesale price.
wholesale_minimum_order_quantity
The wholesale_minimum_order_quantity parameter is used to set the Parent Product Wholesale Minimum Order Quantity option for Variable (parent) products or Wholesale Minimum Order Quantity option for Simple products and Variations. The minimum order quantity value should be an integer.
The parameter data is formatted like this:
"wholesale_minimum_order_quantity": {
"":
}
Example of the request:
"wholesale_minimum_order_quantity": {
"gold_role": 5,
"wholesale_customer": 10
}
The current behavior of this parameter:

If you provide empty string for the _wholesale_minimum_order_quantity_ parameter, it will be ignored as if you don』t set _wholesale_minimum_order_quantity_ parameter at all.
If you provide non-wholesale role keys (regular customer or non-existing roles), it will be ignored. It will only input minimum order quantity with a valid wholesale role.
If you provide string or empty string value as the minimum order quantity, it will be ignored. It will only input integer minimum order quantity.

wholesale_order_quantity_step
The wholesale_order_quantity_step parameter is used to set the Parent Product Wholesale Order Quantity Step option for Variable (parent) products or Wholesale Order Quantity Step option for Simple products and Variations. The order quantity step value should be an integer.
The parameter data is formatted like this:
"wholesale_order_quantity_step": {
"":
}
Example of the request:
"wholesale_order_quantity_step": {
"gold_role": 2,
"wholesale_customer": 3
}
The current behavior of this parameter:

If you provide empty string for the _wholesale_order_quantity_step_ parameter, it will be ignored as if you don』t set _wholesale_order_quantity_step_ parameter at all.
If you provide non-wholesale role keys (regular customer or non-existing roles), it will be ignored. It will only input order quantity step with a valid wholesale role.
If you provide string or empty string value as the order quantity step, it will be ignored. It will only input integer order quantity step.

wholesale_visibility_filter
The wholesale_visibility_filter parameter is used to set the value of Restrict To Wholesale Roles option for Simple and Variable (parent) products, and Wholesale Exclusive Variation option for Variation.
The parameter data is formatted like this:
"wholesale_visibility_filter": [""]
Example of the request:
"wholesale_visibility_filter": ["wholesale_customer","gold_role"]
The current behavior of this parameter:

 If you provide empty string for the _wholesale_visibility_filter_ parameter, it will remove the restriction set previously
If you provide non-wholesale role keys (regular customer or non-existing roles), it will be ignored. It will only save valid wholesale roles.
The wholesale role keys you provide will replace the previous restriction set. So if you have 「Wholesale Customer」 set in your restriction, sending a request with 「gold_role」 won』t add it to the restriction but replace it entirely. So now your restriction is set to 「Gold Role」 only.

ignore_cat_level_wholesale_discount
The ignore_cat_level_wholesale_discount parameter is used to set the value of Disregard Product Category Level Wholesale Discount option under the Wholesale Pricing Options section. The value should be either 「yes」 or 「no」.
Example of the request:
"ignore_cat_level_wholesale_discount": "yes"
The current behavior of this parameter:

If you provide empty string for the _ignore_cat_level_wholesale_discount_ parameter, it will be ignored as if you don』t set _ignore_cat_level_wholesale_discount_ parameter at all.
If you provide value other than 「yes」 or 「no」, it will be ignored as if you don』t set _ignore_cat_level_wholesale_discount_ parameter at all.

ignore_role_level_wholesale_discount
The ignore_role_level_wholesale_discount parameter is used to set the value of Disregard Wholesale Role Level Wholesale Discount option under the Wholesale Pricing Options section. The value should be either 「yes」 or 「no」.
Example of the request:
"ignore_role_level_wholesale_discount": "yes"
The current behavior of this parameter:

If you provide empty string for the _ignore_role_level_wholesale_discount_ parameter, it will be ignored as if you don』t set _ignore_role_level_wholesale_discount_ parameter at all.
If you provide value other than 「yes」 or 「no」, it will be ignored as if you don』t set _ignore_role_level_wholesale_discount_ parameter at all.

Wholesale_quantity_discount_rule_mapping (Variable Product)
The wholesale_quantity_discount_rule_mapping parameter is used to set the rules of Product Quantity Based Wholesale Pricing. Please keep in mind the below format is designed for Variable product only.
The wholesale_quantity_discount_rule_mapping properties:

Attribute
Type
Description

wholesale_role
string
The wholesale role key

start_qty
string
The start quantity for the rule to active

end_qty (optional)
string
The end quantity for the rule to active

price_type
string
The discount rule type. The value should be 「fixed-price」 or 「percent-price」

wholesale_price
string
The discount price or percentage

The parameter data is formatted like this:
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "",
"start_qty": "",
"end_qty": "",
"price_type": "",
"wholesale_price": ""
}
]
Example of the request:
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "10",
"end_qty": "15",
"price_type": "fixed-price",
"wholesale_price": "50"
},
{
"wholesale_role": "wholesale_customer",
"start_qty": "16",
"end_qty": "",
"price_type": "fixed-price",
"wholesale_price": "40"
},
{
"wholesale_role": "gold_role",
"start_qty": "5",
"price_type": "percent-price",
"wholesale_price": "20"
}
]
The current behavior of this parameter:

If you provide empty string for the _wholesale_quantity_discount_rule_mapping_ parameter, it will remove the rules set previously
If you provide non-wholesale role keys (regular customer or non-existing roles) for the _wholesale_role_ property, it will ignore that particular rule.
If you provide non-number value for the _start_qty_ property, it will ignore that particular rule.
If you provide non-number value for the _end_qty_ property, it will ignore that particular rule. You are allowed to set the _end_qty_ property with empty value, though.
If you provide value other than 「percent-price」 for the _price_type_ property, it will ignore that particular rule.
If you provide non-number value for the _wholesale_price_ property, it will ignore that particular rule.
The only optional property is the _end_qty_. Leaving it out or set it to empty means the rule will be active when the quantity is higher than _start_qty_.
The quantity discount rules you provide will replace the previous rules set. If you want to add additional rules, don』t forget to provide the existing rules in your request data too.

wholesale_quantity_discount_rule_mapping (Simple Product and Variation)
The wholesale_quantity_discount_rule_mapping parameter is used to set the rules of Product Quantity Based Wholesale Pricing. Please keep in mind the below format is designed for the Simple Product and Variation.
The wholesale_quantity_discount_rule_mapping properties:

Attribute
Type
Description

wholesale_role
string
The wholesale role key

start_qty
integer
The start quantity for the rule to active

end_qty (optional)
integer
The end quantity for the rule to active

price_type
string
The discount rule type. The value should be 「fixed-price」 or 「percent-price」

wholesale_price
integer
The discount price or percentage

The parameter data is formatted like this:
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "",
"start_qty": "",
"end_qty": "",
"price_type": "",
"wholesale_price": ""
}
]
Example of the request:
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": 10,
"end_qty": 15,
"price_type": "fixed-price",
"wholesale_price": 50
},
{
"wholesale_role": "wholesale_customer",
"start_qty": 16,
"end_qty": "",
"price_type": "fixed-price",
"wholesale_price": 40
},
{
"wholesale_role": "gold_role",
"start_qty": 5,
"price_type": "percent-price",
"wholesale_price": 20
}
]
The current behavior of this parameter:

If you provide empty string for the _wholesale_quantity_discount_rule_mapping_ parameter, it will remove the rules set previously
If you provide non-wholesale role keys (regular customer or non-existing roles) for the _wholesale_role_ property, it will ignore that particular rule.
If you provide non-integer value for the _start_qty_ property, it will ignore that particular rule.
If you provide string value for the _end_qty_ property, it will ignore that particular rule. You are allowed to set the _end_qty_ property with empty value, though.
If you provide value other than 「fixed-price」 or 「percent-price」 for the _price_type_ property, it will ignore that particular rule.
If you provide non-integer value for the _wholesale_price_ property, it will ignore that particular rule.
The only optional property is the _end_qty_. Leaving it out or set it to empty means the rule will be active when the quantity is higher than _start_qty_.
The quantity discount rules you provide will replace the previous rules set. If you want to add additional rules, don』t forget to provide the existing rules in your request data too.

Using the WWPP REST API
To use WWPP REST API, the endpoints should be based on this URL:
/wp-json/wc/v3/wholesale
So when you want to use the Products endpoint, you will need to access it via /wp-json/wc/v3/wholesale/products.
Create a wholesale product
This API helps you create a wholesale product but not regular product (product that doesn』t have wholesale price). Please note that a variable product doesn』t have wholesale prices property (only the variation), so it』s possible to create a variable product without specifying the wholesale prices.
HTTP request
POST /wp-json/wc/v3/wholesale/products
Example
POST: /wp-json/wc/v3/wholesale/products
{
"name":"Wholesale Product",
"type":"simple",
"regular_price":"150",
"wholesale_price":{
"wholesale_customer":140,
"gold_role":110
},
"wholesale_visibility_filter":[
"wholesale_customer",
"gold_role"
],
"ignore_cat_level_wholesale_discount":"yes",
"ignore_role_level_wholesale_discount":"yes",
"wholesale_minimum_order_quantity":{
"wholesale_customer":5,
"gold_role":10
},
"wholesale_order_quantity_step":{
"wholesale_customer":2,
"gold_role":3
},
"wholesale_quantity_discount_rule_mapping":[
{
"wholesale_role":"wholesale_customer",
"start_qty":10,
"end_qty":20,
"price_type":"fixed-price",
"wholesale_price":100
}
]
}
Retrieve a wholesale product
This API lets you retrieve and view a specific wholesale product by ID. Just like the Create API, it won』t retrieve a regular product.
HTTP request
GET /wp-json/wc/v3/wholesale/products/
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the product with. When a product doesn』t have a wholesale price for the particular role, it will show 「Not a wholesale product」 response.

Example
GET: /wp-json/wc/v3/wholesale/products/123?wholesale_role=wholesale_customer
List all wholesale products
This API helps you to view all the wholesale products. Just like retrieving a specific wholesale product, it won』t retrieve regular products.
HTTP request
GET /wp-json/wc/v3/wholesale/products/
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the products with.

Example
GET: /wp-json/wc/v3/wholesale/products?wholesale_role=wholesale_customer
Update a wholesale product
This API lets you make changes to a product. Currently there』s no restriction when updating a product using this API, so you can update regular products or wholesale products.
HTTP request
PUT /wp-json/wc/v3/wholesale/products/
Example
PUT: /wp-json/wc/v3/wholesale/products/123
{
"name":"Updated Wholesale Product",
"wholesale_price":{
"wholesale_customer":140,
"gold_role":110
},
"wholesale_visibility_filter":[
"wholesale_customer",
"gold_role"
],
"ignore_cat_level_wholesale_discount":"yes",
"ignore_role_level_wholesale_discount":"yes",
"wholesale_minimum_order_quantity":{
"wholesale_customer":5,
"gold_role":10
},
"wholesale_order_quantity_step":{
"wholesale_customer":2,
"gold_role":3
},
"wholesale_quantity_discount_rule_mapping":[
{
"wholesale_role":"wholesale_customer",
"start_qty":10,
"end_qty":20,
"price_type":"fixed-price",
"wholesale_price":100
}
]
}
Delete a wholesale product
This API helps you delete a wholesale product. So you won』t be able to use this API to a regular product.
HTTP request
DELETE /wp-json/wc/v3/wholesale/products/
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the product with. If the product doesn』t have wholesale price for the specific role, the API won』t delete the product.

Example
DELETE: /wp-json/wc/v3/wholesale/products/123
Create a wholesale product variation
This API helps you to create a new wholesale product variation. Like the API to create a wholesale product, it doesn』t allow you to create a regular product variation.
HTTP request
POST /wp-json/wc/v3/wholesale/products//variations/
Example
POST: /wp-json/wc/v3/wholesale/products/123/variations/234
{
"regular_price":"150",
"wholesale_price":{
"wholesale_customer":140,
"gold_role":110
},
"wholesale_visibility_filter":[
"wholesale_customer",
"gold_role"
],
"wholesale_minimum_order_quantity":{
"wholesale_customer":5,
"gold_role":10
},
"wholesale_order_quantity_step":{
"wholesale_customer":2,
"gold_role":3
},
"wholesale_quantity_discount_rule_mapping":[
{
"wholesale_role":"wholesale_customer",
"start_qty":10,
"end_qty":20,
"price_type":"fixed-price",
"wholesale_price":100
}
]
}
Retrieve a wholesale product variation
This API lets you retrieve and view a specific wholesale product variation by ID. This API can』t be used to retrieve a specific regular product variation.
HTTP request
GET /wp-json/wc/v3/wholesale/products//variations/
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the variations with. When a variation doesn』t have a wholesale price for the particular role, it will show 「Not a wholesale product」 response.

Example
GET: /wp-json/wc/v3/wholesale/products/123/variations/234?wholesale_role=wholesale_customer
List all wholesale product variations
This API helps you to view all the wholesale product variations in a variable product. If a variation retrieved is not a wholesale product variation, The API won』t list it.
HTTP request
GET /wp-json/wc/v3/wholesale/products//variations
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the products with.

Example
GET: /wp-json/wc/v3/wholesale/products/123/variations?wholesale_role=wholesale_customer
Update a wholesale product variation
This API lets you make changes to a product variation. Currently there』s no restriction for updating via this API, so you can update both regular or wholesale product variations.
HTTP request
PUT /wp-json/wc/v3/wholesale/products//variations/
Example
PUT: /wp-json/wc/v3/wholesale/products/123/variations/234
{
"wholesale_price":{
"wholesale_customer":140,
"gold_role":110
},
"wholesale_visibility_filter":[
"wholesale_customer",
"gold_role"
],
"wholesale_minimum_order_quantity":{
"wholesale_customer":5,
"gold_role":10
},
"wholesale_order_quantity_step":{
"wholesale_customer":2,
"gold_role":3
},
"wholesale_quantity_discount_rule_mapping":[
{
"wholesale_role":"wholesale_customer",
"start_qty":10,
"end_qty":20,
"price_type":"fixed-price",
"wholesale_price":100
}
]
}
Delete a wholesale product variation
This API helps you delete a wholesale product variation.
HTTP request
DELETE /wp-json/wc/v3/wholesale/products//variations/
Available parameters

Parameter
Type
Description

wholesale_role
string
The wholesale role you want to filter the product with. If the product doesn』t have wholesale price for the specific role, the API won』t delete the product.

Example
DELETE: /wp-json/wc/v3/wholesale/products/123/variations/234
Known Issues And Future Improvements
Here are the known bugs and future improvements we are planning to the API integration:

Unable to create wholesale product without providing the wholesale prices, even though the general/role level discount is set or when the product has wholesale category. When a product has wholesale category or the general/role level discount is set, it should count the product as a wholesale product and allow the creation of it.
Include the calculated wholesale prices (final price including tax calculation) and the generated HTML for the wholesale pricing in the API response

Note
Wholesale products vs regular products
Wholesale products are products that have a wholesale price defined. This wholesale price can be set in some places such as on the product itself, on the category, or on the general settings.
For a product to be called a wholesale product, one of these conditions should be true:

The product has wholesale prices set to at least one wholesale role
The product has category with wholesale discount set
The general/role discount is set in 「WooCommerce > Settings > Wholesale Prices > Discount」

See here for a more complete run down of pricing in Wholesale Suite.

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註