This guide explains how to retrieve products with discounts or promotions using Content Service API. By filtering specific fields in the API response, you can easily identify and display products that have either discounts or promotional offers.
Fetching Products:
To fetch the full product catalog, use the following content API call:
curl --location 'https://content-service.tixuk.io/api/v3/products' \
--header 'x-tt-retailer: <your-retailer-id>'
Replace <your-retailer-id>
with your unique identifier. This API call returns a list of products available for your platform. To identify which products have discounts or promotions, you can filter based on the following fields.
Identifying Discounts and Promotions
In the API response, each product has the following fields, that will tell if the product has a promotion:
hasPromotion
: Indicates whether the product has an active promotion. If true, the product has a promotion.promotionLabel
: Provides the name of the promotion, such as "Exclusive Price". This label can be used to display the promotion to customers.
maxDiscountPercentage
: Displays the maximum percentage of savings available for the product as an integer. IfmaxDiscountPercentage > 0
, the product is discounted. To display this to customers, you could use the phraseSave up to [maxDiscountPercentage]%
, for example,Save up to 45%
.
Always use BOTH fields to identify products with promotion:
You should use both conditions together with an OR logic to identify all relevant products.
- Sometimes,
maxDiscountPercentage
may be 0 even if the product is discounted. In these cases,hasPromotion: true
will still indicate that a promotion is active. - Conversely, some products may not have a promotion (
hasPromotion: false
), but still have a non-zeromaxDiscountPercentage
. Therefore, filtering should account for both possible cases.
How to Display Discounts and Promotions:
- If
maxDiscountPercentage
is above 0 displaySave up to [maxDiscountPercentage]%
. - If
promotionLabel
exists displaypromotionLabel
- If both
maxDiscountPercentage
is above 0 andpromotionLabel
exist display both:Save up to [maxDiscountPercentage]%
andpromotionLabel
at the same time. - If
fieldmaxDiscountPercentage
is 0 andpromotionLabel
exists then displaypromotionLabel
only