# Delete Category Discount

This API allows you to delete a wholesale discount of a wholesale roles on a specific category.

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

| Method       | Endpoint                                               |
| ------------ | ------------------------------------------------------ |
| DELETE       | /wp-json/wholesale/v1/category-discount/{category\_id} |
| {% endtab %} |                                                        |

{% tab title="Request Example" %}

#### Postman

Create a wholesale discount for a wholesale customer:

```javascript
DELETE: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
{
    "wholesale_customer"
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

List all wholesale role discounts from a specific category.

After deleting, it will list down the remaining wholesale discounts.

```
DELETE: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
{
    "wholesale_customer"
}

Response:
{
    "message": "Successfully deleted category discount.",
    "data": {
        "Wholesale_bronze_wholesale_discount": 10
    }
}
```

#### Status: 400 Bad Request

The category id does not exist.

```
GET: /wp-json/wholesale/v1/category-discount/{category_id}

Response:
{
    "code": "wholesale_rest_category_discount_cannot_view",
    "message": "Category ID is invalid.",
    "data": {
        "status": 400
    }
}
```

#### Status: 400 Bad Request

The wholesale role is invalid.

```
GET: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
[
    "wholesale_customer_invalid_key"
]

Response:
{
    "code": "wholesale_rest_category_discount_cannot_delete",
    "message": "Make sure wholesale role are valid. Please indicate the wholesale roles you want to remove the discount.",
    "data": {
        "status": 400,
        "invalid_roles": [
            "wholesale_customer_invalid_key"
        ]
    }
}
```

{% endtab %}
{% endtabs %}
