> For the complete documentation index, see [llms.txt](https://rymera.gitbook.io/wholesale-suite-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rymera.gitbook.io/wholesale-suite-api/wholesale-v1-wwpp/products/create-a-wholesale-product.md).

# Create a Wholesale Product

This endpoint allows you to create wholesale product.

{% tabs %}
{% tab title="Request" %}

| POST | /wp-json/wholesale/v1/products |
| ---- | ------------------------------ |

| Body Parameters                              | Required | Type  | Description                                                                                         |
| -------------------------------------------- | -------- | ----- | --------------------------------------------------------------------------------------------------- |
| wholesale\_price                             | no       | array | Wholesale prices for each wholesale role.                                                           |
| categories                                   | no       | array | Wholesale Category IDs. This is needed to attach a proper wholesale meta data flag for the product. |
| wholesale\_visibility\_filter                | no       | array | The wholesale role keys that allowed to see the product.                                            |
| ignore\_cat\_level\_wholesale\_discount      | no       | array | The "Disregard Product Category Level Wholesale Discount" option.                                   |
| ignore\_role\_level\_wholesale\_discount     | no       | array | The "Disregard Wholesale Role Level Wholesale Discount" option.                                     |
| wholesale\_minimum\_order\_quantity          | no       | array | The "Wholesale Minimum Order Quantity" for each role                                                |
| wholesale\_order\_quantity\_step             | no       | array | The "Wholesale Order Quantity Step" for each                                                        |
| wholesale\_quantity\_discount\_rule\_mapping | no       | array | The rules for "Product Quantity Based Wholesale Pricing" option.                                    |

####

#### Extra Properties for wholesale\_quantity\_discount\_rule\_mapping

<table><thead><tr><th>Properties</th><th width="194.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>wholesale_role</td><td>String</td><td>The wholesale role key</td></tr><tr><td>start_qty</td><td>Number</td><td>The min quantity of the quantity range in order to trigger the wholesale discount.</td></tr><tr><td>end_qty</td><td>Number</td><td>The max quantity of the quantity range in order to trigger the wholesale discount.</td></tr><tr><td>price_type</td><td>String</td><td>Either percent-price or fixed-price</td></tr><tr><td>wholesale_price</td><td>Number</td><td>The wholesale price/discount.</td></tr></tbody></table>
{% endtab %}

{% tab title="Request Example" %}
**Postman**

Create Wholesale Product with Wholesale Category

```javascript
POST: /wp-json/wholesale/v1/products

{
  "name" : "Premium Quality Test",
  "type" : "simple",
  "regular_price" : "21.99",
  "categories": [
    { "id": 15 }, { "id": 20 }
  ]
}
```

####

#### Prices Premium Properties:

```javascript
POST: /wp-json/wholesale/v1/products

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"
    }
  ]
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Creating a wholesale product.

```javascript
PUT: wholesale/v1/products/

JSON Body:
{
    "name" : "Premium Quality",
	"type" : "simple",
	"regular_price" : "21.99",
    "wholesale_price" : { 
		"wholesale_customer" : "12"
	},
    "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",
    "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\">&#36;</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

```javascript
POST: /wp-json/wholesale/v1/products/

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"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**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`** are `percent-price` or `fixed-price`.
