# Retrieve a Wholesale Product

This API handles fetching wholesale and non-wholesale product.

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

| Method | Endpoint                                     |
| ------ | -------------------------------------------- |
| GET    | /wp-json/wholesale/v1/products/{product\_id} |

| Path parameters | Required | Type | Description     |
| --------------- | -------- | ---- | --------------- |
| product\_id     | yes      | int  | The product 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. |
| show\_categories            | no       | boolean | Whether show or hide wc `categories` property from the response. The prop is hidden by default using this api.                    |
| show\_meta\_data            | no       | boolean | Whether show or hide wc `meta_data` property from the response. The prop is hidden by default using this api.                     |
| {% endtab %}                |          |         |                                                                                                                                   |

{% tab title="Request Example" %}

#### Postman

Get the product:

```javascript
GET: /wp-json/wholesale/v1/products/{product_id}
```

With wholesale role:

```
GET: /wp-jsonwholesale/v1/products/{product_id}?wholesale_role=wholesale_customer
```

Return only if the product is wholesale:

```
GET: /wp-jsonwholesale/v1/products/{product_id}?wholesale_role=wholesale_customer&return_wholesale_products=true
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Getting a wholesale product

```
GET: wp-json/wholesale/v1/products/{product_id}?wholesale_role=wholesale_customer&return_wholesale_products=true

Response:
{
    "id": 7073,
    "name": "Premium Quality",
    "slug": "premium-quality",
    "permalink": "http://localhost/new/product/premium-quality/",
    "date_created": "2021-10-20T12:55:14",
    "date_created_gmt": "2021-10-20T12:55:14",
    "date_modified": "2021-10-20T12:55:14",
    "date_modified_gmt": "2021-10-20T12:55:14",
    "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.00",
    "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": [
        6363,
        7024,
        6502,
        6361,
        7072
    ],
    "stock_status": "instock",
    "wholesale_data": {
        "wholesale_price": {
            "wholesale_customer": "15"
        },
        "price_html": "<del class=\"original-computed-price\"><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></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\">&#36;</span>15.00</bdi></span> <small class=\"woocommerce-price-suffix wholesale-price-suffix\">inc. VAT</small></ins>\r\n                                        </span>"
    }
}
```

####

#### Status: 403 Forbidden

If getting a non-wholesale product.

```
GET: wp-json/wholesale/v1/products/{product_id}?wholesale_role=wholesale_customer&return_wholesale_products=true

Response:
{
    "code": "wholesale_rest_cannot_view",
    "message": "Not a wholesale product.",
    "data": {
        "status": 403
    }
}
```

####

#### Status: 400 Bad Request

The wholesale role key is invalid.

```
GET: /wp-json/wholesale/v1/products/{product_id}?wholesale_role=invalid_role

Response:
{
    "code": "wholesale_rest_product_cannot_view",
    "message": "Invalid wholesale role.",
    "data": {
        "status": 400
    }
}
```

{% endtab %}
{% endtabs %}

**Note:**

* If you need to filter the results based on the per-user wholesale discount override setting, you need to specify the user ID via `uid` query parameter.
