Implement Badges
If you have enabled Badges, then Constructor will include badge assignment in the API response for a search query or browse page.
Parsing the API response and deciding how badges will display on an item listing page (PLP) will be the responsibility of your team. This includes design aspects, such as what the badges will look like, and could include how many badges you wish to display per item.
The response format for a Badges integration is as follows:
"results": [...
{ "labels": {
# Context-based badges
"__cnstrc_is_context_bestseller": { "display_name": "is_context_bestseller"},
"__cnstrc_is_context_trending_now": { "display_name": "is_context_trending_now"}
# Global based badges
"__cnstrc_is_new_arrivals": { "display_name": "is_new_arrivals"},
"__cnstrc_is_bestseller": { "display_name": "is_bestseller"},
"__cnstrc_is_trending_now": { "display_name": "trending_now"}
}, ...
}, ...
]
Note: If Constructor does not assign a badge to an item, then the labels
field will be empty.
Updated 4 days ago