Handling promotion codes
This article will guide you through how to work with promotion codes. Ucommerce supports the get, remove and add requests for promotion codes on a basket. The Postman collection will be used for all examples.
Prerequisites
accessToken
from Connect flow.basketId
from Creating a basket.
Adding promotion codes
When a promotion code is added, you will get the list of all promotion codes on the basket.
Request:
curl -D- -X POST https://umbracodemo1.ucommerce.net/api/v1/baskets/{baketId}/promotion-codes/{code} \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \ -d '{ "PriceGroupId": "{PriceGroupId}", "CultureCode": "{CultureCode}" }'
Response:
{ "promotionCodes": [ { "code": "{promotionCode}", } ] }
Getting promotion codes
Request:
curl -D- -X GET https://umbracodemo1.ucommerce.net/api/v1/baskets/{baketId}/promotion-codes \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \
Response:
{ "promotionCodes": [ { "code": "{promotionCode}", } ] }
Removing promotion codes
Request:
curl -D- -X DELETE https://umbracodemo1.ucommerce.net/api/v1/baskets/{baketId}/promotion-codes/{code} \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \ -d '{ "PriceGroupId": "{PriceGroupId}", "CultureCode": "{CultureCode}" }'
Response:
{ "promotionCodes": [ ] }
Possible errors that may occur
Error | Description |
---|---|
BadRequest (400) | Price Group does not exist. |
Unauthorized (401) | The token is expired. |
NotFound (404) | Basket does not exist; Promotion code does not exists. |