docs
  1. Features
  2. Promotions & Campaigns
  3. Composables

Interfaces

ModuleOptions

Properties

PropertyType
autoImports?boolean

PromotionReductionItem

Properties

PropertyType
promotionBasketItemPromotion
totalCentAmount

TierProgress

Properties

PropertyTypeDescription
effectPromotionEffectThe discount effect of the tier when unlocked.
movCentAmountThe minimum total basket value needed to complete the tier.
percentnumberThe percentage of total completion at which this tier is unlocked. 0 meaning 0% and 1 meaning 100%.
progressnumberA decimal fraction representing the progress towards completing the tier. 0 meaning 0% and 1 meaning 100%.
remainingCentAmountThe missing basket value needed to complete the tier.

UseApplyPromotionsOptions

Properties

PropertyTypeDescription
basketRef<null | BasketResponseData<..., ...>>The current basket which promotions will be applied to or removed from
getOrderedPromotions?GetOrderedPromotionsFunction 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

PropertyTypeDescription
totalPromotionReductionsComputedRef<CentAmount>Total amount of all promotion reductions
validPromotionsComputedRef<PromotionReductionItem>A list unique Promotions, together with their total reduction amount.

UsePromotionGiftsReturn

Properties

PropertyType
hasMultipleFreeGiftsComputedRef<boolean>
productsRef<null | ...>
variantIdsComputedRef<number>

UsePromotionMOVProgressReturn

Properties

PropertyTypeDescription
discountComputedRef<CentAmount>The combined discount value which is applied by the promotion.
isMOVPromotionAppliedComputedRef<boolean>Flag indicating if the promotion is applied to the current basket.
minimumOrderValueReachedComputedRef<boolean>Flag indicating whether the minimum order value is reached.
progressComputedRef<number>A decimal fraction representing the progress towards reaching the minimum order amount. 0 meaning 0% and 1 meaning 100%.
remainingComputedRef<CentAmount>The missing basket value needed to reach the minimum order value.

UsePromotionTierProgressReturn

Properties

PropertyTypeDescription
completeComputedRef<boolean>Flag indicating whether all tiers have unlocked.
discountComputedRef<CentAmount>The combined discount value which is applied by the promotion.
isPromotionAppliedComputedRef<boolean>Flag indicating if the promotion is applied to the current basket.
progressComputedRef<number>A decimal fraction representing the progress towards unlocking all tiers. 0 meaning 0% and 1 meaning 100%.
remainingComputedRef<CentAmount>The remaining value to unlock the next tier
tiersComputedRef<TierProgress>-

Type Aliases

GetOrderedPromotions()

Parameters

ParameterType
promotionsApplicablePromotion

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

ParameterTypeDescription
basketMaybeRefOrGetter<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

ParameterTypeDescription
optionsUseApplyPromotionsOptionsAn object containing options for applying promotions.

Returns

An object containing methods for applying promotions.

NameTypeDescription
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

ParameterTypeDescription
basketMaybeRefOrGetter<undefined | BasketResponseData<..., ...>>The basket to extract promotion data from.

Returns

UseBasketPromotionsReturn

An UseBasketPromotionsReturn object containing reactive promotion data.


usePromotionGifts()

A composable used to fetch gift products for a buy X get Y promotion.

Parameters

ParameterTypeDescription
_buyXGetYPromotionMaybeRefOrGetter<Promotion<PromotionEffect>>The buy X get Y promotion to fetch gift products for.
key?stringThe 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

ParameterTypeDescription
movPromotionMaybeRefOrGetter<Promotion<PromotionEffect>>The promotion to track.
minimumOrderValueMaybeRefOrGetter<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

ParameterTypeDescription
promotionMaybeRefOrGetter<Promotion<...> & Required<...>>The promotion to track.

Returns

UsePromotionTierProgressReturn & Promise<UsePromotionTierProgressReturn>

An object containing information about the promotion's tiers, progress, and discount.