> 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-wwp/variations/update-a-wholesale-variation.md).

# Update a Wholesale Variation

This API handles updating a wholesale or non-wholesale variation.

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

| Method | Endpoint                                                                 |
| ------ | ------------------------------------------------------------------------ |
| PUT    | /wp-json/wholesale/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. |

| Body Parameters        | Required | Type  | Description               |
| ---------------------- | -------- | ----- | ------------------------- |
| wholesale\_price       | yes      | array | The wholesale price.      |
| wholesale\_sale\_price | no       | array | The wholesale sale price. |
| {% endtab %}           |          |       |                           |

{% tab title="Request Example" %}

#### Postman

Update variation wholesale price

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

JSON Body
{
    "wholesale_price" : { 
        "wholesale_customer" : "6"
    },
    // With sale price.
    "wholesale_sale_price" : { 
        "wholesale_customer" : "4"
    }
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Updating wholesale price.

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

JSON Body
{
    "wholesale_price" : { 
        "wholesale_customer" : "6"
    },
    // With sale price.
    "wholesale_sale_price" : { 
        "wholesale_customer" : "4"
    },
}

Response:
{
    "id": 4305,
    "date_created": "2021-03-15T05:47:31",
    "date_created_gmt": "2021-03-15T05:47:31",
    "date_modified": "2021-03-15T05:50:52",
    "date_modified_gmt": "2021-03-15T05:50:52",
    "description": "",
    "permalink": "https://example.com/product/ship-your-idea-variable-2/?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": "6"
        },
        // With sale price.
        "wholesale_sale_price": {
            "wholesale_customer": "4"
        }
    }
}
```

####

#### Status: 400 Bad Request

The wholesale role key and wholesale price are invalid.

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

{% endtab %}
{% endtabs %}
