docs
  1. Changelogs
  2. Storefront SDKs
  3. @scayle/storefront-promotions

@scayle/storefront-promotions

3.0.0

Major Changes

  • Update useApplyPromotions composable to support applying multiple promotions on basket items.
    The function applyPromotions can now apply multiple promotions to basket items. No changes are required for your existing implementation.

Minor Changes

  • Updated useApplyPromotions composable to support removing multiple promotions from a basket item.
    The functions removePromotion, removePromotionById and removeAllPromotionsFromBasket now removes multiple promotions based in the new promotions attribute of the basket item. No changes are required for your existing implementation.
  • Updated useAppliedPromotionCodes composable to support multiple promotions on basket items.
    If present, appliedCodes now returns a record of promotion codes, including cases where the multiple promotion codes are applied to a basket item. No changes are required for your existing implementation.
  • Updated useBasketPromotions composable to support multiple promotions on basket items.
    The computed property validPromotions now returns a list of unique promotions including cases where multiple promotion are applied to a basket item, together with their total reduction amount. No changes are required for your existing implementation.
  • Deprecated isFreeGiftBasketItem in favor of isBuyXGetYBasketItem.
    The new isBuyXGetYBasketItem utility returns true for basket items eligible for buy-x-get-y promotions and correctly handles cases where multiple promotions apply to the same item. No changes are required for your existing implementation.

2.3.0

Minor Changes

  • The useApplyPromotions composable now includes a removeAllPromotionsFromBasket function, providing an easy way to clear all promotions from a basket in a single action. Under the hood, the existing removePromotionById function has also been refactored to use the more efficient bulkUpdatePromotions Storefront API endpoint via the updatePromotions RPC method. For more details, see the Storefront API documentation.

2.2.3

Patch Changes

  • To improve stability, the applyPromotions function of the useApplyPromotions composable has been updated to prevent infinite re-application loops when multiple promotions target the same basket item. It now only replaces an existing promotion if a newly applicable one has a higher priority, ensuring predictable behavior.

2.2.2

Patch Changes

  • Added explicit return type for usePromotionGifts composable to resolve unknown type issues with the return values.
    The new return type of the composable is:

    This change has no impact on existing implementations of the composable.

2.2.1

Patch Changes

  • Resolved issue were promotion code could not be removed.
    Removed the deprecated promotionCode parameter from the updateBasketItem RPC call for removePromotion function in useApplyPromotions composable.

2.2.0

Minor Changes

  • Added a new usePromotionTierProgress composable which can be used to get the progress and status of tiered promotions. In addition to returning the overall progress of the promotion, it also returns the progress state of the individual tiers of the promotion.

2.1.0

Minor Changes

  • Added a new composable useAppliedPromotionCodes. This composable returns the promotion codes which have been applied to the current basket, including the promotion details and the item keys of the items to which each code applies.
  • Added removePromotionById to useApplyPromotions which can be used to remove promotions from all basket items which have a promotion with the specified ID.

2.0.1

Patch Changes

  • applyPromotions now accepts MaybeRef<Basket> instead of Ref<Basket> allowing for more flexibility in usage.

2.0.0

Major Changes

  • Updated useApplyPromotions to require a basket reference. This basket will be updated when calling functions such as applyPromotions and removePromotion. The basket passed to applyPromotions will still be used as the source of the applicablePromotions, but it is now optional and the current basket will be used as a fallback.
    Before:

    After:

Minor Changes

  • Updated useApplyPromotions to include a removePromotion function. This can be used to remove an applied promotion from a basket item.

1.1.0

Minor Changes

  • Updated useApplyPromotions to include the promotion code when applicable.

1.0.0

Major Changes

  • Breaking: The following functions are no longer provided by @scayle/storefront-promotions: isFreeGiftEligible, getVariantIds and isGiftInBasket. If necessary, these functions should be re-implemented within your application.
    Below are examples of how these functions were previously implemented:

Minor Changes

  • Simplified the logic of the isFreeGiftBasketItem function. It now checks the following criteria:
    • The promotion exists on the basket item
    • The promotion is valid
    • The promotion is a isBuyXGetY promotion

0.3.0

Minor Changes

  • Removed the duplicate utility function isPromotionGiftAddedToBasket, as its functionality is already covered by isGiftInBasket.

0.2.0

Minor Changes

  • Update to @nuxt/module-builder@1. This version of Nuxt Module Builder is ESM-only, so CommonJS (.cjs) files will no longer be built or distributed with the package. However as of Nuxt 3, only esm is used so this should not have any impact as this module does not support Nuxt 2.

0.1.1

Patch Changes

  • Removed imports from indirect dependencies and rely on direct imports from @scayle/storefront-nuxt

0.1.0

Minor Changes

  • Initial release of @scayle/storefront-promotions. This package separates promotion functionality from the SCAYLE Storefront Application, facilitating easier integration and maintenance. It includes the following RPC's, composable and utility functions.
    • RPC's:
      • getPromotionGiftProducts
    • Composables:
      • useApplyPromotions
      • useBasketPromotions
      • usePromotionMOVProgress
      • usePromotionGifts
    • Utilities:
      • getBasketTotalWithoutPromotions
      • getTotalReductionsByCategory
      • sortPromotionsByPriority
      • isGiftConditionMet
      • isBuyXGetYType
      • isAutomaticDiscountType
      • getVariantIds
      • isFreeGiftEligible
      • isFreeGiftBasketItem
      • isGiftInBasket
      • isPromotionGiftAddedToBasket