-
Notifications
You must be signed in to change notification settings - Fork 200
@W-19980361 Rule based bonus products- Work Item 2- update display logic #3408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sf-shikhar-prasoon
merged 17 commits into
feature/bonus-products-rule-based-v3
from
t/cc-sharks/W-19980361/rule-based-w2/main
Oct 23, 2025
Merged
@W-19980361 Rule based bonus products- Work Item 2- update display logic #3408
sf-shikhar-prasoon
merged 17 commits into
feature/bonus-products-rule-based-v3
from
t/cc-sharks/W-19980361/rule-based-w2/main
Oct 23, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
sf-xingquan-jin
approved these changes
Oct 17, 2025
Base automatically changed from
t/cc-sharks/W-18957985/rule-based-w1/main
to
feature/bonus-products-rule-based-v3
October 21, 2025 15:17
Resolved conflicts: - app/utils/bonus-product/discovery.js: Kept refactored version with processBonusProducts helper - app/hooks/use-bonus-product-selection-modal/use-bonus-product-data.test.js: Kept w2's additional tests for rule-based products
cca5519
into
feature/bonus-products-rule-based-v3
41 of 42 checks passed
sf-shikhar-prasoon
added a commit
that referenced
this pull request
Oct 25, 2025
…3418) * @W-18957985- Product Search Integration & Rule-Based Detection (#3396) * 1. use search endpoint * 2 add rule based detection * 3. update discovery logic * add tests, update bundle size limit, update changelog * @W-19980361 Rule based bonus products- Work Item 2- update display logic (#3408) * 1. use search endpoint * 2 add rule based detection * 3. update discovery logic * cleanup. remove unused code * add tests, update bundle size limit, update changelog * fix header counts * fix flasing, re-rendering * pr comments + lint * @W-19980361 fix 2 bugs- selection count & flashing due to re-renders (#3421) * fix header counts * fix flasing, re-rendering * pr comments + lint * add param &refine=pmpt=bonus for promotion type * pr comments * use commerce sdk * add const- limit=50 | replace harded Search Param values * remove function breakdown change * update changelog * refactor. re-use * fix: prevent promotion message flashing when changing product variant… (#3428) * fix tests * Rule-Based Bonus Product Promotions Enhancement This PR enhances the existing rule-based bonus product promotions feature by adding proper variant eligibility checking. Previously, rule-based promotions could not accurately determine which specific product variants qualified for a promotion. This enhancement introduces a qualifying products lookup system that uses the product search API to fetch and validate eligible variants, ensuring that only products that truly qualify can trigger bonus product selection UI and functionality. Key Changes: 1. New Hook: useRuleBasedQualifyingProducts - Added to app/hooks/use-rule-based-bonus-products.js - Fetches qualifying products for rule-based promotions using productSearch API - Uses refinement parameters: pmid=${promotionId} and pmpt=qualifying - Returns a Set of qualifying product IDs for efficient lookup - Supports variant eligibility checking by examining both variant and master product IDs 2. Enhanced Promotion Eligibility Logic - Updated getPromotionIdsForProduct() in app/utils/bonus-product/common.js - Distinguishes between list-based and rule-based promotions - Added fallback logic to check master product IDs when variants don't directly qualify - Filters promotion IDs to only return those the product actually qualifies for 3. Qualifying Products Map Integration - Added ruleBasedQualifyingProductsMap parameter throughout the bonus product utility chain - Updated useBasketProductsWithPromotions() hook to fetch and return qualifying products map - Propagated the map through all relevant functions and components 4. Updated Function Signatures - isAutomaticPromotion() - shouldShowBonusProductSelection() - getBonusProductsForSpecificCartItem() - getBonusProductsInCartForProduct() - getAvailableBonusItemsForProduct() - getRemainingAvailableBonusProductsForProduct() 5. Component Updates - Cart Page: Destructures and passes ruleBasedQualifyingProductsMap - Add to Cart Modal: Uses qualifying products map for eligibility checks - Cart Product List: Accepts and forwards ruleBasedQualifyingProductsMap prop 6. Comprehensive Test Updates - Updated all test files to distinguish list-based vs rule-based promotions - Added new test cases for rule-based promotion eligibility scenarios - Enhanced test coverage across all bonus product utility test files Backward Compatibility: - All changes are backward compatible with existing list-based promotions - Default parameter values ensure functions work without the new map - Existing tests updated to explicitly mark promotions as list-based * fix: prevent promotion message flashing when changing product variant (#3431) * fix: prevent promotion flash by keeping previous data during variant changes - Add keepPreviousData option parameter to useProductViewModal hook - Pass keepPreviousData: true in BonusProductViewModal to maintain UI stability - Prevents promotion message from clearing while fetching new variant data * chore: trigger CI * remove those stable references * revert last changes * bundle size limit update * @W-20037720: Not allow duplicate items to appear in the cart (#3433) * Fixed duplicating bonus products in the UI * Fixed issue with list based not rendering properly * Update cart-product-list-with-grouped-bonus-products.jsx Signed-off-by: Daniel Diaz <[email protected]> * Fixed lint errors --------- Signed-off-by: Daniel Diaz <[email protected]> --------- Signed-off-by: Daniel Diaz <[email protected]> Co-authored-by: sf-xingquan-jin <[email protected]> Co-authored-by: cboscenco <[email protected]> Co-authored-by: Daniel Diaz <[email protected]>
shethj
pushed a commit
that referenced
this pull request
Oct 31, 2025
…3418) * @W-18957985- Product Search Integration & Rule-Based Detection (#3396) * 1. use search endpoint * 2 add rule based detection * 3. update discovery logic * add tests, update bundle size limit, update changelog * @W-19980361 Rule based bonus products- Work Item 2- update display logic (#3408) * 1. use search endpoint * 2 add rule based detection * 3. update discovery logic * cleanup. remove unused code * add tests, update bundle size limit, update changelog * fix header counts * fix flasing, re-rendering * pr comments + lint * @W-19980361 fix 2 bugs- selection count & flashing due to re-renders (#3421) * fix header counts * fix flasing, re-rendering * pr comments + lint * add param &refine=pmpt=bonus for promotion type * pr comments * use commerce sdk * add const- limit=50 | replace harded Search Param values * remove function breakdown change * update changelog * refactor. re-use * fix: prevent promotion message flashing when changing product variant… (#3428) * fix tests * Rule-Based Bonus Product Promotions Enhancement This PR enhances the existing rule-based bonus product promotions feature by adding proper variant eligibility checking. Previously, rule-based promotions could not accurately determine which specific product variants qualified for a promotion. This enhancement introduces a qualifying products lookup system that uses the product search API to fetch and validate eligible variants, ensuring that only products that truly qualify can trigger bonus product selection UI and functionality. Key Changes: 1. New Hook: useRuleBasedQualifyingProducts - Added to app/hooks/use-rule-based-bonus-products.js - Fetches qualifying products for rule-based promotions using productSearch API - Uses refinement parameters: pmid=${promotionId} and pmpt=qualifying - Returns a Set of qualifying product IDs for efficient lookup - Supports variant eligibility checking by examining both variant and master product IDs 2. Enhanced Promotion Eligibility Logic - Updated getPromotionIdsForProduct() in app/utils/bonus-product/common.js - Distinguishes between list-based and rule-based promotions - Added fallback logic to check master product IDs when variants don't directly qualify - Filters promotion IDs to only return those the product actually qualifies for 3. Qualifying Products Map Integration - Added ruleBasedQualifyingProductsMap parameter throughout the bonus product utility chain - Updated useBasketProductsWithPromotions() hook to fetch and return qualifying products map - Propagated the map through all relevant functions and components 4. Updated Function Signatures - isAutomaticPromotion() - shouldShowBonusProductSelection() - getBonusProductsForSpecificCartItem() - getBonusProductsInCartForProduct() - getAvailableBonusItemsForProduct() - getRemainingAvailableBonusProductsForProduct() 5. Component Updates - Cart Page: Destructures and passes ruleBasedQualifyingProductsMap - Add to Cart Modal: Uses qualifying products map for eligibility checks - Cart Product List: Accepts and forwards ruleBasedQualifyingProductsMap prop 6. Comprehensive Test Updates - Updated all test files to distinguish list-based vs rule-based promotions - Added new test cases for rule-based promotion eligibility scenarios - Enhanced test coverage across all bonus product utility test files Backward Compatibility: - All changes are backward compatible with existing list-based promotions - Default parameter values ensure functions work without the new map - Existing tests updated to explicitly mark promotions as list-based * fix: prevent promotion message flashing when changing product variant (#3431) * fix: prevent promotion flash by keeping previous data during variant changes - Add keepPreviousData option parameter to useProductViewModal hook - Pass keepPreviousData: true in BonusProductViewModal to maintain UI stability - Prevents promotion message from clearing while fetching new variant data * chore: trigger CI * remove those stable references * revert last changes * bundle size limit update * @W-20037720: Not allow duplicate items to appear in the cart (#3433) * Fixed duplicating bonus products in the UI * Fixed issue with list based not rendering properly * Update cart-product-list-with-grouped-bonus-products.jsx Signed-off-by: Daniel Diaz <[email protected]> * Fixed lint errors --------- Signed-off-by: Daniel Diaz <[email protected]> --------- Signed-off-by: Daniel Diaz <[email protected]> Co-authored-by: sf-xingquan-jin <[email protected]> Co-authored-by: cboscenco <[email protected]> Co-authored-by: Daniel Diaz <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
skip changelog
Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
@W-19980361 Rule based bonus products- Work Item 2- update display logic
This PR is against another branch of mine so that the diff better indicates work done in this PR
once that branch's PR is merged, i'll edit this PR's base branch to point to the feature branch
Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization