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:

  1. Learn how to set up your WooCommerce API key here: https://docs.woocommerce.com/document/woocommerce-rest-api/
  2. Learn how to use WooCommerce REST API with PHP here: https://packagist.org/packages/automattic/woocommerce
  3. Learn how to use WooCommerce REST API with Postman here: https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API
  4. 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:

[table width =”100%” style =”table-striped table-bordered” responsive =”true”]
[table_head]
[th_column]Attribute[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[th_column]Available On[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_price[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Prices set on the backend[/row_column]
[row_column]Simple, Variation[/row_column]
[/table_row]
[table_row]
[row_column]variable_level_wholesale_minimum_order_quantity[/row_column]
[row_column]array[/row_column]
[row_column]The Parent Product Wholesale Minimum Order Quantity[/row_column]
[row_column]Variable[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_minimum_order_quantity[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Minimum Order Quantity[/row_column]
[row_column]Simple, Variation[/row_column]
[/table_row]
[table_row]
[row_column]variable_level_wholesale_order_quantity_step[/row_column]
[row_column]array[/row_column]
[row_column]The Parent Product Wholesale Order Quantity Step[/row_column]
[row_column]Variable[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_order_quantity_step[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Order Quantity Step[/row_column]
[row_column]Simple, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wwpp_product_wholesale_visibility_filter[/row_column]
[row_column]array[/row_column]
[row_column]The Restrict To Wholesale Roles for Simple and Variable, the Wholesale Exclusive Variation for Variation[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wwpp_ignore_cat_level_wholesale_discount[/row_column]
[row_column]string[/row_column]
[row_column]The Disregard Product Category Level Wholesale Discount option[/row_column]
[row_column]Simple, Variable[/row_column]
[/table_row]
[table_row]
[row_column]wwpp_ignore_role_level_wholesale_discount[/row_column]
[row_column]string[/row_column]
[row_column]The Disregard Wholesale Role Level Wholesale Discount option[/row_column]
[row_column]Simple, Variable[/row_column]
[/table_row]
[table_row]
[row_column]wwpp_enable_quantity_discount_rule[/row_column]
[row_column]string[/row_column]
[row_column]The Enable further wholesale pricing discounts based on quantity purchased? option[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wwpp_quantity_discount_rule_mapping[/row_column]
[row_column]array[/row_column]
[row_column]The Product Quantity Based Wholesale Pricing rules[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[/table_body]
[/table]

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": {
    "<wholesale role key>": "<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": {
    "<wholesale role key>": "<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": {
    "<wholesale role key>": "<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": {
    "<wholesale role key>": "<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": {
    "<wholesale role key>": "<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": ["<wholesale role key>"]

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": "<wholesale role key>",
        "start_qty": "<start quantity>",
        "end_qty": "<end quantity>",
        "price_type": "<rule type (fixed-price or percent-price)>",
        "wholesale_price": "<rule price/discount>"
    }
]

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:

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameters[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[th_column]Available For[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_price[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Prices set on the backend[/row_column]
[row_column]Simple, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_minimum_order_quantity[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Minimum Order Quantity[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_order_quantity_step[/row_column]
[row_column]array[/row_column]
[row_column]The Wholesale Order Quantity Step[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_visibility_filter[/row_column]
[row_column]array[/row_column]
[row_column]The Restrict To Wholesale Roles for Simple and Variable, the Wholesale Exclusive Variation for Variation[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[table_row]
[row_column]ignore_cat_level_wholesale_discount[/row_column]
[row_column]string[/row_column]
[row_column]The Disregard Product Category Level Wholesale Discount option[/row_column]
[row_column]Simple, Variable[/row_column]
[/table_row]
[table_row]
[row_column]ignore_role_level_wholesale_discount[/row_column]
[row_column]string[/row_column]
[row_column]The Disregard Wholesale Role Level Wholesale Discount option[/row_column]
[row_column]Simple, Variable[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_quantity_discount_rule_mapping[/row_column]
[row_column]array[/row_column]
[row_column]The Product Quantity Based Wholesale Pricing rules[/row_column]
[row_column]Simple, Variable, Variation[/row_column]
[/table_row]
[/table_body]
[/table]

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": {
    "<wholesale role key>": <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": {
"<wholesale role key>": <minimum order quantity>
}

Example of the request:

"wholesale_minimum_order_quantity": {
"gold_role": 5,
"wholesale_customer": 10
}

The current behavior of this parameter:

  1. 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.
  2. 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.
  3. 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": {
"<wholesale role key>": <order quantity step>
}

Example of the request:

"wholesale_order_quantity_step": {
"gold_role": 2,
"wholesale_customer": 3
}

The current behavior of this parameter:

  1. 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.
  2. 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.
  3. 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": ["<wholesale role key>"]

Example of the request:

"wholesale_visibility_filter": ["wholesale_customer","gold_role"]

The current behavior of this parameter:

  1.  If you provide empty string for the _wholesale_visibility_filter_ parameter, it will remove the restriction set previously
  2. If you provide non-wholesale role keys (regular customer or non-existing roles), it will be ignored. It will only save valid wholesale roles.
  3. 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:

  1. 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.
  2. 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:

  1. 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.
  2. 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:

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Attribute[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]The wholesale role key[/row_column]
[/table_row]
[table_row]
[row_column]start_qty[/row_column]
[row_column]string[/row_column]
[row_column]The start quantity for the rule to active[/row_column]
[/table_row]
[table_row]
[row_column]end_qty (optional)[/row_column]
[row_column]string[/row_column]
[row_column]The end quantity for the rule to active[/row_column]
[/table_row]
[table_row]
[row_column]price_type[/row_column]
[row_column]string[/row_column]
[row_column]The discount rule type. The value should be “fixed-price” or “percent-price”[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_price[/row_column]
[row_column]string[/row_column]
[row_column]The discount price or percentage[/row_column]
[/table_row]
[/table_body]
[/table]

The parameter data is formatted like this:

"wholesale_quantity_discount_rule_mapping": [
    {
        "wholesale_role": "<wholesale role key>",
        "start_qty": "<start quantity>",
        "end_qty": "<end quantity>",
        "price_type": "<rule type>",
        "wholesale_price": "<rule price/discount>"
    }
]

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:

  1. If you provide empty string for the _wholesale_quantity_discount_rule_mapping_ parameter, it will remove the rules set previously
  2. If you provide non-wholesale role keys (regular customer or non-existing roles) for the _wholesale_role_ property, it will ignore that particular rule.
  3. If you provide non-number value for the _start_qty_ property, it will ignore that particular rule.
  4. 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.
  5. If you provide value other than “percent-price” for the _price_type_ property, it will ignore that particular rule.
  6. If you provide non-number value for the _wholesale_price_ property, it will ignore that particular rule.
  7. 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_.
  8. 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:

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Attribute[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]The wholesale role key[/row_column]
[/table_row]
[table_row]
[row_column]start_qty[/row_column]
[row_column]integer[/row_column]
[row_column]The start quantity for the rule to active[/row_column]
[/table_row]
[table_row]
[row_column]end_qty (optional)[/row_column]
[row_column]Integer[/row_column]
[row_column]The end quantity for the rule to active[/row_column]
[/table_row]
[table_row]
[row_column]price_type[/row_column]
[row_column]string[/row_column]
[row_column]The discount rule type. The value should be “fixed-price” or “percent-price”[/row_column]
[/table_row]
[table_row]
[row_column]wholesale_price[/row_column]
[row_column]integer[/row_column]
[row_column]The discount price or percentage[/row_column]
[/table_row]
[/table_body]
[/table]

The parameter data is formatted like this:

"wholesale_quantity_discount_rule_mapping": [
    {
        "wholesale_role": "<wholesale role key>",
        "start_qty": "<start quantity>",
        "end_qty": "<end quantity>",
        "price_type": "<rule type (fixed-price or percent-price)>",
        "wholesale_price": "<rule price/discount>"
    }
]

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:

  1. If you provide empty string for the _wholesale_quantity_discount_rule_mapping_ parameter, it will remove the rules set previously
  2. If you provide non-wholesale role keys (regular customer or non-existing roles) for the _wholesale_role_ property, it will ignore that particular rule.
  3. If you provide non-integer value for the _start_qty_ property, it will ignore that particular rule.
  4. 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.
  5. If you provide value other than “fixed-price” or “percent-price” for the _price_type_ property, it will ignore that particular rule.
  6. If you provide non-integer value for the _wholesale_price_ property, it will ignore that particular rule.
  7. 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_.
  8. 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

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]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.[/row_column]
[/table_row]
[/table_body]
[/table]

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

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]The wholesale role you want to filter the products with.[/row_column]
[/table_row]
[/table_body]
[/table]

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

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]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.[/row_column]
[/table_row]
[/table_body]
[/table]

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/<product_id>/variations/<variation_id>

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/<product_id>/variations/<variation_id>

Available parameters

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]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.[/row_column]
[/table_row]
[/table_body]
[/table]

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/<product_id>/variations

Available parameters

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]The wholesale role you want to filter the products with.[/row_column]
[/table_row]
[/table_body]
[/table]

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/<product_id>/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/<product_id>/variations/<variation_id>

Available parameters

[table width =”100%” style =”table-striped table-bordered” responsive =”false”]
[table_head]
[th_column]Parameter[/th_column]
[th_column]Type[/th_column]
[th_column]Description[/th_column]
[/table_head]
[table_body]
[table_row]
[row_column]wholesale_role[/row_column]
[row_column]string[/row_column]
[row_column]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[/row_column]
[/table_row]
[/table_body]
[/table]

 

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:

  1. 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.
  2. Allow creating, listing, updating, and deleting wholesale roles via the API
  3. 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:

  1. The product has wholesale prices set to at least one wholesale role
  2. The product has category with wholesale discount set
  3. 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.

in WooCommerce Wholesale Prices Premium

Solve The Big Three Problems With Wholesaling In WooCommerce

Add wholesale pricing to products   Streamline your ordering   Register & manage wholesale customer

Explore The Plugin Suite  

[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']