Composables
useApplyPromotions
Composable streamline the application of promotions to a basket.
Parameters
options
getOrderedPromotions
: Function that can be used to change the prioritization of promotions. By default promotions are sorted by priority.
Returns
applyPromotions
: An object containing methods for applying promotions.
useProductPromotions
A composable for extracted product promotions data.
Parameters
productItem
Product on which promotions will be extracted
Returns
promotion: First promotion of the product
isGiftAddedToBasket: A computed ref that indicates whether a promotion gift is added to basket or not.
areGiftConditionsMet: A computed ref that indicates whether a promotion gift conditions are met or not
usePromotionCustomData
A composable to easily access custom data of a promotion.
Parameters
_promotion
The promotion of witch the custom data is taken from.
Returns
headline
: The headline of the promotion, defaulting to the promotion's name if no custom headline is provided.
subline
: Optional subline text associated with the promotion.
conditions
: Conditions or terms related to the promotion, if any.
colorStyle
: The color style of the promotion, derived from its properties.
hideCountdown
: Indicates whether to hide the countdown timer for the promotion.
link
: A link associated with the promotion, if any; defaults to undefined if no custom link is provided.
expirationDate
: The date and time when the promotion schedule ends.
usePromotionGifts
A composable used to fetch gift products for a buy X get Y promotion.
Parameters
_buyXGetYPromotion
The buy X get Y promotion to fetch gift products for.
key
The key to use for caching the RPC call.
Returns
An object containing the gift products the variant ids of the gift items and a flag indicating if there are multiple free gifts.
variantIds: Variant IDs of the gift item
products: Gift products
hasMultipleFreeGifts: Flag to check if there are multiple free gifts
usePromotionMOVProgress
A composable used to extract minimum order value information from a promotion.
Parameters
movPromotion
The promotion to track.
minimumOrderValue
The minimum order value to reach.
Returns
progress
: A percentage value representing the progress towards reaching the minimum order amount.
minimumOrderValueReached
: Flag indicating whether the minimum order value is reached
remaining
: The missing basket value needed to reach the minimum order value.
discount
: The combined discount value which is applied by the promotion.
isMOVPromotionApplied
: Flag indicating if the promotion is applied to the current basket.
useBasketPromotionReductions
A composable for manipulating and extracting basket promotion reductions data.
Parameters
cost
The total cost of the basket
items
The items in the basket
Returns
totalPromotionReductions
: Total amount of all promotion reductions
basketPromotionSummaries
: A list of all promotions together with the total reductions ot the promotion
useBasketPromotions
A composable for extracting promotion data from basket.
Parameters
basket
The basket to extract promotion data from.
Returns
totalPromotionReductions
: Total amount of all promotion reductions
promotionReductions
: A list of summed up reductions, grouped by the causing promotion
uniqueAppliedPromotions
: A list of unique promotions applied to the basket.