Wholesale Suite API
  • REST API
  • wholesale/v1 (Free)
    • Products
      • List All Wholesale Products
      • Retrieve a Wholesale Product
      • Create a Wholesale Product
      • Update a Wholesale Product
      • Delete a Wholesale Product
      • Batch Update Products
    • Variations
      • List All Wholesale Variations
      • Retrieve a Wholesale Variation
      • Create a Wholesale Variation
      • Update a Wholesale Variation
      • Delete a Wholesale Variation
      • Batch Update Variations
    • Wholesale Role
      • List Wholesale Roles
      • Retrieve a Wholesale Role
      • Update a Wholesale Role
  • wholesale/v1 (Premium)
    • Products
      • List All Wholesale Products
      • Retrieve a Wholesale Product
      • Create a Wholesale Product
      • Update a Wholesale Product
      • Delete a Wholesale Product
      • Batch Update Products
    • Variations
      • List All Wholesale Variations
      • Retrieve a Wholesale Variation
      • Create a Wholesale Variation
      • Update a Wholesale Variation
      • Delete a Wholesale Variation
      • Batch Update Variations
    • Wholesale Role
      • List Wholesale Roles
      • Retrieve a Wholesale Role
      • Create a Wholesale Role
      • Update a Wholesale Role
      • Delete a Wholesale Role
    • Category Discounts
      • List Category Discounts
      • Retrieve Category Discount
      • Create Category Discount
      • Update Category Discount
      • Delete Category Discount
    • General Discounts
      • List General Discounts
      • Retrieve Specific Role Discount
      • Create a General Discount
      • Update a general Discount
      • Delete a General Discount
    • Bundle
      • Create Bundle Product
      • Batch Update
    • Composite
      • Create Composite Product
      • Batch Update
Powered by GitBook
On this page

Was this helpful?

  1. wholesale/v1 (Premium)
  2. Variations

Create a Wholesale Variation

This API allows you to create wholesale variation.

Method

Endpoint

POST

/wp-json/wholesale/v1/products/{variable_id}/variations

Path parameters

Required

Type

Description

variable_id

yes

int

The variable ID.

Body Parameters

Required

Type

Description

wholesale_price

no

array

Wholesale prices for each wholesale role.

wholesale_visibility_filter

no

array

The wholesale role keys that allowed to see the product.

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

Properties
Type
Description

wholesale_role

String

The wholesale role key

start_qty

Number

The min quantity of the quantity range in order to trigger the wholesale discount.

end_qty

Number

The max quantity of the quantity range in order to trigger the wholesale discount.

price_type

String

Either percent-price or fixed-price

wholesale_price

Number

The wholesale price/discount.

Postman

POST: /wp-json/wholesale/v1/products/123/variations

JSON Body:
{
    "regular_price": "19.00",
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "option": "Red"
        }
    ],
    "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"
    },
    "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

Successfully created

POST: wholesale/v1/products/{variable_id}/variations/

JSON Body:
{
    "regular_price": "19.00",
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "option": "Red"
        }
    ],
    "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"
    },
    "wholesale_quantity_discount_rule_mapping": [
        {
            "wholesale_role": "wholesale_customer",
            "start_qty": "11",
            "end_qty": "20",
            "price_type": "percent-price",
            "wholesale_price": "20"
        }
    ]
}

Response:
{
    "id": 7083,
    "date_created": "2021-10-21T04:00:46",
    "date_created_gmt": "2021-10-21T04:00:46",
    "date_modified": "2021-10-21T04:00:46",
    "date_modified_gmt": "2021-10-21T04:00:46",
    "description": "",
    "permalink": "https://example.com/product/variable-test/?attribute_pa_color=red",
    "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,
    "low_stock_amount": null,
    "weight": "",
    "dimensions": {
        "length": "",
        "width": "",
        "height": ""
    },
    "shipping_class": "",
    "shipping_class_id": 0,
    "image": null,
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "option": "Red"
        }
    ],
    "menu_order": 0,
    "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_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": "wholesale_customer",
                    "start_qty": "11",
                    "end_qty": "20",
                    "price_type": "percent-price",
                    "wholesale_price": "20"
                }
            ]
        }
    }
}

Status: 400 Bad Request

If invalid wholesale role and wholesale price parameter.

GET: /wp-json/wholesale/v1/products/{variation_id}/variations/{variation_id}?wholesale_role=invalid_role

JSON Body:
{
    "regular_price": "19.00",
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "option": "Black"
        }
    ],
    "wholesale_price": {
        "wholesale_role_key_invalid": "wholesale_price_invalid"
    }
}

Response:
{
    "code": "wholesale_rest_variation_cannot_create",
    "message": "Unable to create. Invalid wholesale price.",
    "data": {
        "status": 400,
        "invalid_roles": [
            "wholesale_role_key_invalid"
        ],
        "invalid_wholesale_price": {
            "wholesale_role_key_invalid": "wholesale_price_invalid"
        }
    }
}
PreviousRetrieve a Wholesale VariationNextUpdate a Wholesale Variation

Last updated 3 years ago

Was this helpful?