# Retrieve a Wholesale Variation

This API handles fetching wholesale and non-wholesale variation.

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

| Method | Endpoint                                                                 |
| ------ | ------------------------------------------------------------------------ |
| GET    | /wp-json/wholseale/v1/products/{variable\_id}/variations/{variation\_id} |

| Path parameters | Required | Type | Description       |
| --------------- | -------- | ---- | ----------------- |
| variable\_id    | yes      | int  | The variable ID.  |
| variation\_id   | yes      | int  | The variation 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. |
| {% endtab %}                |          |         |                                                                                                                                   |

{% tab title="Request Example" %}

#### Postman

Fetch variation without filter

```javascript
GET: /wp-json/wholesale/v1/products/{variable_id}/variations/{variation_id}
```

Fetch variation for wholesale customer

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

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Fetch wholesale variations.

```
{
    "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"
        ],
        "wwpp_enable_quantity_discount_rule": true
    }
}
```

####

#### Status: 401 Unauthorized

The wholesale product is restricted.

```
GET wp-json/wholesale/v1/products/{variable_id}/variations/{variation_id}

Response:
{
    "code": "wholesale_rest_product_cannot_view",
    "message": "The product is restricted. Please provide the correct wholesale_role parameter for this product.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

**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.
* If **Only Show Wholesale Products To Wholesale Customers** is enabled, then you need to specify `wholesale_role` parameter to get correct data.
