@scayle/storefront-promotions
3.1.2
Patch Changes
- Use latest
[email protected]for build. Compatibility with previous version has not changed and is specified via packagepeerDependenciesand Nuxtcompatibilityflag.
3.1.1
Patch Changes
- Refactored
applyPromotionsto avoid unnecessary updates of the basket ref for each promotion.
Previously,applyPromotionsupdated the basket ref for each promotion, and then once more at the end of the loop. This caused redundant updates and triggered unnecessary UI re-renders. The function now updates the basket ref only once at the end of the loop, resolving performance issues in the Storefront Application and preventing multiple promotions from causing excessive UI updates. No changes are required for existing implementations.
Before:
After:
3.1.0
Minor Changes
- Created a new function
isComboDealTypeto check if the promotion is of typeComboDealEffect
Usage:
Patch Changes
- Enhanced the
usePromotionMOVProgresscomposable with the newpromotionsattribute.
The computed propertiesisMOVPromotionApplied,isPromotionAppliedanddiscountnow checks if the promotion is applied to the current basket based on thepromotionsattribute. Note: Upgrading to this version will break theisMOVPromotionApplied,isPromotionAppliedanddiscountcomputed properties if you did not migrate to the newpromotionsattribute. If you are using theusePromotionMOVProgresscomposable, no changes are required—its parameters and return values remain the same.
Before:
After:
3.0.0
Major Changes
- Update
useApplyPromotionscomposable to support applying multiple promotions on basket items.
The functionapplyPromotionscan now apply multiple promotions to basket items. No changes are required for your existing implementation.
Minor Changes
- Updated
useApplyPromotionscomposable to support removing multiple promotions from a basket item.
The functionsremovePromotion,removePromotionByIdandremoveAllPromotionsFromBasketnow removes multiple promotions based in the newpromotionsattribute of the basket item. No changes are required for your existing implementation. - Updated
useAppliedPromotionCodescomposable to support multiple promotions on basket items.
If present,appliedCodesnow 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
useBasketPromotionscomposable to support multiple promotions on basket items.
The computed propertyvalidPromotionsnow 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
isFreeGiftBasketItemin favor ofisBuyXGetYBasketItem.
The newisBuyXGetYBasketItemutility returnstruefor 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
useApplyPromotionscomposable now includes aremoveAllPromotionsFromBasketfunction, providing an easy way to clear all promotions from a basket in a single action. Under the hood, the existingremovePromotionByIdfunction has also been refactored to use the more efficientbulkUpdatePromotionsStorefront API endpoint via theupdatePromotionsRPC method. For more details, see the Storefront API documentation.
2.2.3
Patch Changes
- To improve stability, the
applyPromotionsfunction of theuseApplyPromotionscomposable 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
usePromotionGiftscomposable to resolveunknowntype 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 deprecatedpromotionCodeparameter from theupdateBasketItemRPC call forremovePromotionfunction inuseApplyPromotionscomposable.
2.2.0
Minor Changes
- Added a new
usePromotionTierProgresscomposable 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
removePromotionByIdtouseApplyPromotionswhich can be used to remove promotions from all basket items which have a promotion with the specified ID.
2.0.1
Patch Changes
applyPromotionsnow acceptsMaybeRef<Basket>instead ofRef<Basket>allowing for more flexibility in usage.
2.0.0
Major Changes
- Updated
useApplyPromotionsto require a basket reference. This basket will be updated when calling functions such asapplyPromotionsandremovePromotion. The basket passed toapplyPromotionswill still be used as the source of theapplicablePromotions, but it is now optional and the current basket will be used as a fallback.
Before:
After:
Minor Changes
- Updated
useApplyPromotionsto include aremovePromotionfunction. This can be used to remove an applied promotion from a basket item.
1.1.0
Minor Changes
- Updated
useApplyPromotionsto include the promotion code when applicable.
1.0.0
Major Changes
- Breaking: The following functions are no longer provided by
@scayle/storefront-promotions:isFreeGiftEligible,getVariantIdsandisGiftInBasket. 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
isFreeGiftBasketItemfunction. It now checks the following criteria:- The promotion exists on the basket item
- The promotion is valid
- The promotion is a
isBuyXGetYpromotion
0.3.0
Minor Changes
- Removed the duplicate utility function
isPromotionGiftAddedToBasket, as its functionality is already covered byisGiftInBasket.
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:
useApplyPromotionsuseBasketPromotionsusePromotionMOVProgressusePromotionGifts
- Utilities:
getBasketTotalWithoutPromotionsgetTotalReductionsByCategorysortPromotionsByPriorityisGiftConditionMetisBuyXGetYTypeisAutomaticDiscountTypegetVariantIdsisFreeGiftEligibleisFreeGiftBasketItemisGiftInBasketisPromotionGiftAddedToBasket
- RPC's: