Skip to main content

Cart Coupons API

List Cart Coupons

GET /cart/coupons

There are no parameters required for this endpoint.

curl "https://example-store.com/wp-json/wc/store/v1/cart/coupons"

Example response:

[
{
"code": "20off",
"type": "fixed_cart",
"totals": {
"currency_code": "GBP",
"currency_symbol": "£",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "£",
"currency_suffix": "",
"total_discount": "1667",
"total_discount_tax": "333"
},
"_links": {
"self": [
{
"href": "http://local.wordpress.test/wp-json/wc/store/v1/cart/coupons/20off"
}
],
"collection": [
{
"href": "http://local.wordpress.test/wp-json/wc/store/v1/cart/coupons"
}
]
}
}
]

Single Cart Coupon

Get a single cart coupon.

GET /cart/coupons/:code
AttributeTypeRequiredDescription
codestringYesThe coupon code of the cart coupon to retrieve.
curl "https://example-store.com/wp-json/wc/store/v1/cart/coupons/20off"

Example response:

{
"code": "halfprice",
"type": "percent",
"totals": {
"currency_code": "GBP",
"currency_symbol": "£",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "£",
"currency_suffix": "",
"total_discount": "9950",
"total_discount_tax": "0"
}
}

Add Cart Coupon

Apply a coupon to the cart. Returns the new coupon object that was applied, or an error if it was not applied.

POST /cart/coupons/
AttributeTypeRequiredDescription
codestringYesThe coupon code you wish to apply to the cart.
curl --request POST https://example-store.com/wp-json/wc/store/v1/cart/coupons?code=20off

Example response:

{
"code": "20off",
"type": "percent",
"totals": {
"currency_code": "GBP",
"currency_symbol": "£",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "£",
"currency_suffix": "",
"total_discount": "1667",
"total_discount_tax": "333"
}
}

Delete Single Cart Coupon

Delete/remove a coupon from the cart.

DELETE /cart/coupons/:code
AttributeTypeRequiredDescription
codestringYesThe coupon code you wish to remove from the cart.
curl --request DELETE https://example-store.com/wp-json/wc/store/v1/cart/coupons/20off

Delete All Cart Coupons

Delete/remove all coupons from the cart.

DELETE /cart/coupons/

There are no parameters required for this endpoint.

curl --request DELETE https://example-store.com/wp-json/wc/store/v1/cart/coupons

Example response:

[]