Interfaces
ModuleOptions
Properties
PromotionReductionItem
Properties
TierProgress
Properties
UseApplyPromotionsOptions
Properties
Property | Type | Description |
---|---|---|
basket | Ref <null | BasketResponseData <..., ...>> | The current basket which promotions will be applied to or removed from |
getOrderedPromotions? | GetOrderedPromotions | Function that can be used to change the prioritization of promotions. By default promotions are sorted by priority. Param List of promotions that should be reordered. |
UseBasketPromotionsReturn
Properties
Property | Type | Description |
---|---|---|
totalPromotionReductions | ComputedRef <CentAmount > | Total amount of all promotion reductions |
validPromotions | ComputedRef <PromotionReductionItem > | A list unique Promotions, together with their total reduction amount. |
UsePromotionGiftsReturn
Properties
Property | Type |
---|---|
hasMultipleFreeGifts | ComputedRef <boolean > |
products | Ref <null | ...> |
variantIds | ComputedRef <number > |
UsePromotionMOVProgressReturn
Properties
UsePromotionTierProgressReturn
Properties
Property | Type | Description |
---|---|---|
complete | ComputedRef <boolean > | Flag indicating whether all tiers have unlocked. |
discount | ComputedRef <CentAmount > | The combined discount value which is applied by the promotion. |
isPromotionApplied | ComputedRef <boolean > | Flag indicating if the promotion is applied to the current basket. |
progress | ComputedRef <number > | A decimal fraction representing the progress towards unlocking all tiers. 0 meaning 0% and 1 meaning 100%. |
remaining | ComputedRef <CentAmount > | The remaining value to unlock the next tier |
tiers | ComputedRef <TierProgress > | - |
Type Aliases
GetOrderedPromotions()
Parameters
Parameter | Type |
---|---|
promotions | ApplicablePromotion |
Returns
ApplicablePromotion
Variables
module
Functions
useAppliedPromotionCodes()
This composable returns a computed property which computes a list of the promotion codes that have been applied to the provided basket. It includes the code, the promotion, and a list of basket item keys which it has been applied to.
Parameters
Parameter | Type | Description |
---|---|---|
basket | MaybeRefOrGetter <null | BasketResponseData <..., ...>> | The basket from which promotions will be read |
Returns
ComputedRef
<Record
<string
, {
itemKeys
: ...;
promotion
: ...;
}>>
useApplyPromotions()
Composable which streamlines the application of promotions to a basket.
Parameters
Parameter | Type | Description |
---|---|---|
options | UseApplyPromotionsOptions | An object containing options for applying promotions. |
Returns
An object containing methods for applying promotions.
Name | Type | Description |
---|---|---|
applyPromotions() | (sourceBasket? : ... | ...) => Promise <...> | Applies currently applicable promotions to the basket in deterministic iterations until no further changes occur. - Uses the provided ordering function (defaults to ascending priority) to evaluate applicable promotions. - Applies at most one promotion per iteration and then re-evaluates with the updated basket to surface newly applicable promotions. - For a basket item that already has a promotion, a replacement occurs only when a newly applicable promotion has higher priority; equal or lower priority promotions are skipped. - Updates the shared basket ref as promotions are applied. Subsequent reads will see the latest state. - Emits debug logs about iterations and skip reasons; there are no info/error logs unless an RPC call fails. - Idempotent with respect to the final state: calling it again without state changes results in no updates. |
removeAllPromotionsFromBasket() | () => Promise <...> | - |
removePromotion() | (basketItem : BasketItem ) => Promise <...> | Removes all applied promotions from a basket item |
removePromotionById() | (promotionId : string ) => Promise <...> | Removes from all basket items promotions which match the provided promotion ID. Uses a single bulk update request to clear promotions for matching items. |
useBasketPromotions()
A composable for extracting promotion data from basket.
Parameters
Parameter | Type | Description |
---|---|---|
basket | MaybeRefOrGetter <undefined | BasketResponseData <..., ...>> | The basket to extract promotion data from. |
Returns
An UseBasketPromotionsReturn object containing reactive promotion data.
usePromotionGifts()
A composable used to fetch gift products for a buy X get Y promotion.
Parameters
Parameter | Type | Description |
---|---|---|
_buyXGetYPromotion | MaybeRefOrGetter <Promotion <PromotionEffect >> | The buy X get Y promotion to fetch gift products for. |
key? | string | The key to use for caching the RPC call. |
Returns
UsePromotionGiftsReturn
& Promise
<UsePromotionGiftsReturn
>
An object containing the gift products the variant ids of the gift items and a flag indicating if there are multiple free gifts.
usePromotionMOVProgress()
A composable used to extract minimum order value information from a promotion.
Parameters
Parameter | Type | Description |
---|---|---|
movPromotion | MaybeRefOrGetter <Promotion <PromotionEffect >> | The promotion to track. |
minimumOrderValue | MaybeRefOrGetter <CentAmount > | The minimum order value to reach. |
Returns
UsePromotionMOVProgressReturn
& Promise
<UsePromotionMOVProgressReturn
>
An object containing information about the promotion's minimum order value, progress, and discount.
usePromotionTierProgress()
A composable used to extract progress and milestones from a tiered promotion.
Parameters
Parameter | Type | Description |
---|---|---|
promotion | MaybeRefOrGetter <Promotion <...> & Required <...>> | The promotion to track. |
Returns
UsePromotionTierProgressReturn
& Promise
<UsePromotionTierProgressReturn
>
An object containing information about the promotion's tiers, progress, and discount.