You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This filtered list was correctly passed to getValidDiscountRules (line 286–290) to determine which discount rules apply. However, inside the discount loop, when building kitItems (the actual items the discount gets applied to), the code was reverting back to params.items instead of itemsForKit. This meant freebie items could slip into kitItems and have a discount incorrectly applied to them.
The Fix
All three kitItems assignment branches now use itemsForKit:
Case
Before
After
Filter by product_ids
params.items.filter(...)
itemsForKit.filter(...)
Filter by category_ids
params.items.filter(...)
itemsForKit.filter(...)
No filter (catch-all)
[...params.items]
[...itemsForKit]
Assessment
The fix is correct. It closes the gap between how discount rules are validated (using itemsForKit) and how discounted items are selected (now also using itemsForKit).
The change is consistent — all three branches are updated, preventing any path from re-introducing freebie items.
The recommendBuyTogether logic (line 348+) still uses params.items directly, which is intentional — buy-together recommendations should consider the full cart, not just non-freebie items. This is unaffected and correct.
No new variables, abstractions, or risky changes are introduced.
No issues found. The PR is clean and the fix is minimal and appropriate.
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
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.
No description provided.