List All Wholesale Variations
This API allows you to fetch all wholesale variations.
Method
Endpoint
GET
/wp-json/wholesale/v1/products/{variable_id}/variations
Path parameters
Required
Type
Description
variable_id
yes
int
The variable ID.
Query Parameters
Required
Type
Description
uid
no
int
The user ID.
wholesale_role
no
string
The wholesale role key.
return_wholesale_products
no
boolean
Return only products with wholesale price. This parameter is dependent on the wholesale_role
parameter. Default value is false.
Status: 200 OK
List all wholesale variations.
GET: /wp-json/wholesale/v1/products/{variable_id}/variations?wholesale_role=wholesale_customer&return_wholesale_products=true
Response:
[
{
"id": 4311,
"date_created": "2021-03-15T15:04:22",
"date_created_gmt": "2021-03-15T15:04:22",
"date_modified": "2021-03-15T15:04:22",
"date_modified_gmt": "2021-03-15T15:04:22",
"description": "",
"permalink": "https://example.com/product/ship-your-idea-variable/?attribute_size=M",
"sku": "",
"price": "19.00",
"regular_price": "19.00",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"on_sale": false,
"status": "publish",
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": null,
"attributes": [
{
"id": 0,
"name": "Size",
"option": "M"
}
],
"menu_order": 0,
"wholesale_data": {
"wholesale_price": {
"wholesale_customer": "12"
},
"wwpp_product_wholesale_visibility_filter": [
"all"
],
"price_html": "<del class=\"original-computed-price\"><span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>19.00</bdi></span></del><span style=\"display: block;\" class=\"wholesale_price_container\">\r\n <span class=\"wholesale_price_title\">Wholesale Price:</span>\r\n <ins><span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>13.20</bdi></span> <small class=\"woocommerce-price-suffix wholesale-price-suffix\"></small></ins>\r\n </span>",
"wwpp_enable_quantity_discount_rule": true,
"wwpp_quantity_discount_rule_mapping": {
"desc": "Quantity based discounts available based on how many items are in your cart.",
"mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "11",
"end_qty": "20",
"price_type": "percent-price",
"wholesale_price": "20",
"calculated_price": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>10.56</bdi></span>"
}
]
}
}
},
{
"id": 4310,
"date_created": "2021-03-15T15:03:51",
"date_created_gmt": "2021-03-15T15:03:51",
"date_modified": "2021-03-15T15:03:51",
"date_modified_gmt": "2021-03-15T15:03:51",
"description": "",
"permalink": "https://example.com/product/ship-your-idea-variable/?attribute_size=S",
"sku": "",
"price": "19.00",
"regular_price": "19.00",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"on_sale": false,
"status": "publish",
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": null,
"attributes": [
{
"id": 0,
"name": "Size",
"option": "S"
}
],
"menu_order": 0,
"wholesale_data": {
"wholesale_price": {
"wholesale_customer": "12"
},
"wwpp_product_wholesale_visibility_filter": [
"all"
],
"price_html": "<del class=\"original-computed-price\"><span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>19.00</bdi></span></del><span style=\"display: block;\" class=\"wholesale_price_container\">\r\n <span class=\"wholesale_price_title\">Wholesale Price:</span>\r\n <ins><span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>13.20</bdi></span> <small class=\"woocommerce-price-suffix wholesale-price-suffix\"></small></ins>\r\n </span>",
"wwpp_enable_quantity_discount_rule": true,
"wwpp_quantity_discount_rule_mapping": {
"desc": "Quantity based discounts available based on how many items are in your cart.",
"mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "11",
"end_qty": "20",
"price_type": "percent-price",
"wholesale_price": "20",
"calculated_price": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>10.56</bdi></span>"
}
]
}
}
}
]
Status: 400 Bad Request
The wholesale role key is invalid
GET: /wp-json/wholesale/v1/products/{variation_id}/variations?wholesale_role=invalid_role
Response:
{
"code": "wholesale_rest_product_cannot_view",
"message": "Invalid wholesale role.",
"data": {
"status": 400
}
}
Note:
If you need to filter the results based on the per-user wholesale override setting you need to specify the user ID via
uid
query parameter.
Last updated