Update a Wholesale Product
This endpoint allows you to make changes to a wholesale product.
Postman
Update a product or a wholesale product.
PUT: /wp-json/wholesale/v1/products/{product_id}
JSON Body:
{
"name" : "Premium Quality Test",
"type" : "simple",
"regular_price" : "21.99",
"wholesale_price" : {
"wholesale_customer" : "12",
"silver" : "13"
},
"wholesale_visibility_filter": "wholesale_customer",
"wholesale_minimum_order_quantity": {
"wholesale_customer": "2",
"sample_role": "3"
},
"wholesale_order_quantity_step": {
"wholesale_customer": "6",
"sample_role": "7"
},
"ignore_cat_level_wholesale_discount": "yes",
"ignore_role_level_wholesale_discount": "yes",
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "11",
"end_qty": "20",
"price_type": "percent-price",
"wholesale_price": "20"
}
]
}
Status: 200 OK
Creating a wholesale product.
PUT: /wp-json/wholesale/v1/products/{product_id}
JSON Body:
{
"name" : "Premium Quality Updated",
"type" : "simple",
"regular_price" : "21.99",
"wholesale_price" : {
"wholesale_customer" : "12",
"silver" : "13"
},
"wholesale_visibility_filter": "wholesale_customer",
"wholesale_minimum_order_quantity": {
"wholesale_customer": "2",
"sample_role": "3"
},
"wholesale_order_quantity_step": {
"wholesale_customer": "6",
"sample_role": "7"
},
"ignore_cat_level_wholesale_discount": "yes",
"ignore_role_level_wholesale_discount": "yes",
"wholesale_quantity_discount_rule_mapping": [
{
"wholesale_role": "wholesale_customer",
"start_qty": "11",
"end_qty": "20",
"price_type": "percent-price",
"wholesale_price": "20"
}
]
}
Response:
{
"id": 7072,
"name": "Premium Quality Updated",
"slug": "premium-quality",
"permalink": "https://example.com/product/premium-quality/",
"date_created": "2021-10-20T12:41:58",
"date_created_gmt": "2021-10-20T12:41:58",
"date_modified": "2021-10-20T15:06:42",
"date_modified_gmt": "2021-10-20T15:06:42",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "",
"short_description": "",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"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,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"low_stock_amount": null,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0",
"rating_count": 0,
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"tags": [],
"images": [],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"price_html": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>21.99</bdi></span> <small class=\"woocommerce-price-suffix\">inc. VAT</small>",
"related_ids": [
6503,
7073,
6361,
6351,
7047
],
"stock_status": "instock",
"wholesale_data": {
"wholesale_price": {
"wholesale_customer": "12"
},
"wholesale_minimum_order_quantity": {
"wholesale_customer": "2"
},
"wholesale_order_quantity_step": {
"wholesale_customer": "6"
},
"wwpp_product_wholesale_visibility_filter": [
"wholesale_customer"
],
"wwpp_ignore_cat_level_wholesale_discount": "yes",
"wwpp_ignore_role_level_wholesale_discount": "yes",
"wwpp_enable_quantity_discount_rule": "yes",
"wwpp_quantity_discount_rule_mapping": {
"desc": "Quantity based discounts available based on how many items are in your cart.",
"mapping": [
{
"wholesale_role": "WholesaleBronze",
"start_qty": "22",
"end_qty": "33",
"wholesale_discount": "12"
},
{
"wholesale_role": "wholesale_customer",
"start_qty": "22",
"end_qty": "33",
"wholesale_discount": "7"
}
]
}
}
}
Status: 400 Bad Request
Invalid Wholesale Role key and Wholesale Price
PUT: /wp-json/wholesale/v1/products/{product_id}
JSON Body:
{
"name" : "Premium Quality",
"type" : "simple",
"regular_price" : "21.99",
"wholesale_price" : {
"invalid_role_key" : "invalid_wholesale_price"
}
}
Response:
{
"code": "wholesale_rest_product_cannot_update",
"message": "Unable to update. Invalid wholesale price.",
"data": {
"status": 400,
"invalid_roles": [
"invalid_role_key"
],
"invalid_wholesale_price": {
"invalid_role_key": "invalid_wholesale_price"
}
}
}
Note:
Since v1.27, it is now allowed to create both non-wholesale and wholesale products. Meaning providing wholesale_price is optional.
To disable the "Product Quantity Based Wholesale Pricing" option, set the value to empty string. Ex.
wholesale_quantity_discount_rule_mapping: ""
Possible values for
price_type
arepercent-price
orfixed-price
.
Last updated