applied_coupon_codes
Description
This link relationship returns a collection of resources. You can easily paginate through this collection using the hypermedia links provided and the link relationships of first, prev, next, and last. Scroll down to view a representation of a single resource embedded within this collection.
Actions
- GET
- View a list of applied_coupon_codes
- POST
- Create a new applied_coupon_code
- HEAD
- Get just the header response
- OPTIONS
- Get a response explaining which HTTP methods are supported
Example Representation
{ "_links": { "curies": [ { "name": "fx", "href": "https://api.foxycart.com/rels/{rel}", "templated": true } ], "self": { "href": "...", "title": "This Collection" }, "first": { "href": "...?offset=0", "title": "First Page of this Collection" }, "prev": { "href": "...?offset=0", "title": "Previous Page of this Collection" }, "next": { "href": "...?offset=0", "title": "Next Page of this Collection" }, "last": { "href": "...?offset=0", "title": "Last Page of this Collection" } }, "_embedded": { "fx:applied_coupon_codes": [...] }, "total_items": "5", "returned_items": 5, "limit": 20, "offset": 0 }
<?xml version="1.0" encoding="UTF-8"?> <resource href="..."> <link rel="self" href="..." title="This Collection"/> <link rel="first" href="...?offset=0" title="First Page of this Collection"/> <link rel="prev" href="...?offset=0" title="Previous Page of this Collection"/> <link rel="next" href="...?offset=0" title="Next Page of this Collection"/> <link rel="last" href="...?offset=0" title="Last Page of this Collection"/> <resource href="..." rel="https://api.foxycart.com/rels/applied_coupon_code"> ... </resource> <total_items>5</total_items> <returned_items>5</returned_items> <limit>20</limit> <offset>0</offset> </resource>
{ "properties": { "total_items": "5", "returned_items": 5, "limit": 20, "offset": 0 }, "entities": [...], "links": [ { "rel": [ "self" ], "href": "..." }, { "rel": [ "first" ], "href": "...?offset=0" }, { "rel": [ "prev" ], "href": "...?offset=0" }, { "rel": [ "next" ], "href": "...?offset=0" }, { "rel": [ "last" ], "href": "...?offset=0" } ], "actions": [ ] }
Embedded Resource: applied_coupon_code
Description
This resource represents a coupon which has been applied to a shopping cart. It contains link relationships to the coupon, coupon code, and the cart it is applied to.
To apply a coupon to a cart, POST a code
value to the applied_coupon_codes
collection of the cart. Include a parameter for ignore_usage_limits
set to true
to allow the coupon to be added to the cart, even if it has expired or the number of uses per coupon, code or customer has reached their maximums.
If you want to apply an externally controlled coupon to a cart then first you should have externally_controlled_coupon_id
which can be obtained by creating a coupon with coupon_discount_type
parameter set to externally_controlled
.
Then make a POST request with data like this:
{ "externally_controlled_coupon_id": 801, "name": "Special External Coupon!", "code": "summer23", "amount": -1, "is_taxable": false }Where
externally_controlled_coupon_id
is the id of an already existing externally controlled coupon. The code
and name
we will show on the cart, checkout and receipts. Set is_taxable
to true
to apply taxes before this coupon's discount is applied. Check with your tax professional if you have questions about how you should calculate taxes.
externally_controlled_coupon
can be used for two use cases:
- You want to give discount to the user (the normal use). In this case
amount
should be negative. - You want to charge user for some fees or some other price adjustments. In this case
amount
should be positive.
Actions
- GET
- View a applied_coupon_code
- DELETE
- View a applied_coupon_code
- HEAD
- Get just the header response
- OPTIONS
- Get a response explaining which HTTP methods are supported
Properties
Property | Description | Type | Constraints |
---|---|---|---|
code | The coupon code applied to this cart. | String | Read only |
name | The name of this coupon. | String | Read only, returned only for externally_controlled coupons |
amount | The amount of discount applied by this coupon. | Double | Read only, returned only for externally_controlled coupons |
date_created | The date this resource was created. | Date | Read only |
date_modified | The date this resource was last modified. | Date | Read only |
Example Representation
{ "_links": { "curies": [ { "name": "fx", "href": "https://api.foxycart.com/rels/{rel}", "templated": true } ], "self": { "href": "https://api-sandbox.foxycart.com/applied_coupon_codes/8353", "title": "Applied Coupon Code" }, "fx:store": { "href": "https://api-sandbox.foxycart.com/stores/66", "title": "This Store" }, "fx:cart": { "href": "https://api-sandbox.foxycart.com/carts/4856839", "title": "This Cart" }, "fx:coupon": { "href": "https://api-sandbox.foxycart.com/coupons/244", "title": "This Coupon" }, "fx:coupon_code": { "href": "https://api-sandbox.foxycart.com/coupon_codes/6540", "title": "This Coupon Code" } }, "code": "test", "date_created": 2015-04-27T13:42:55-0700, "date_modified": 2015-04-27T13:42:55-0700 }
<?xml version="1.0" encoding="UTF-8"?> <resource href="https://api-sandbox.foxycart.com/applied_coupon_codes/8353" rel="https://api.foxycart.com/rels/applied_coupon_code"> <link rel="self" href="https://api-sandbox.foxycart.com/applied_coupon_codes/8353" title="Applied Coupon Code"/> <link rel="https://api.foxycart.com/rels/store" href="https://api-sandbox.foxycart.com/stores/66" title="This Store"/> <link rel="https://api.foxycart.com/rels/cart" href="https://api-sandbox.foxycart.com/carts/4856839" title="This Cart"/> <link rel="https://api.foxycart.com/rels/coupon" href="https://api-sandbox.foxycart.com/coupons/244" title="This Coupon"/> <link rel="https://api.foxycart.com/rels/coupon_code" href="https://api-sandbox.foxycart.com/coupon_codes/6540" title="This Coupon Code"/> <date_created>2015-04-27T13:42:55-0700</date_created> <date_modified>2015-04-27T13:42:55-0700</date_modified> </resource>
{ "class": [ "applied_coupon_code" ], "properties": { "code": "test", "date_created": 2015-04-27T13:42:55-0700, "date_modified": 2015-04-27T13:42:55-0700 }, "links": [ { "rel": [ "self" ], "href": "https://api-sandbox.foxycart.com/applied_coupon_codes/8353" }, { "rel": [ "https://api.foxycart.com/rels/store" ], "href": "https://api-sandbox.foxycart.com/stores/66" }, { "rel": [ "https://api.foxycart.com/rels/transaction" ], "href": "https://api-sandbox.foxycart.com/carts/4856839" }, { "rel": [ "https://api.foxycart.com/rels/coupon" ], "href": "https://api-sandbox.foxycart.com/coupons/244" }, { "rel": [ "https://api.foxycart.com/rels/coupon_code" ], "href": "https://api-sandbox.foxycart.com/coupon_codes/6540" } ] }
Zoomable Resources
This resource has no linked resources which can be "zoomed" in on, filtered and embedded within this resource.