Skip to content

Clamp cart amount when variant changes to respect sellable quantity - #682

Merged
mnindrazaka merged 1 commit into
mainfrom
claude/cool-davinci-av861i
Oct 3, 2026
Merged

mnindrazaka merged 1 commit into
mainfrom
claude/cool-davinci-av861i

Conversation

@mnindrazaka

Copy link
Copy Markdown
Collaborator

Summary

When a menu item variant is changed, the cart amount is now automatically clamped to the new variant's sellable quantity if the current amount exceeds it. This prevents users from adding more items than available for the newly selected variant.

Changes

  • Extracted amount-clamping logic into a reusable clampAmountToVariant helper function that respects a variant's sellableQuantity and ensures a minimum of 1
  • Applied clamping when a variant is selected via SELECT_OPTION_VALUE action, in addition to the existing clamping on CHANGE_AMOUNT
  • Added two test cases:
    • Verifies amount is lowered when switching to a variant with lower sellable quantity
    • Verifies amount is preserved when it already fits within the new variant's limit

Implementation Details

The clampAmountToVariant function centralizes the clamping logic: it caps the amount to the variant's sellableQuantity (if the variant is sellable) and enforces a minimum of 1. This same logic now applies both when the user manually changes the amount and when the variant selection changes.

https://claude.ai/code/session_01ENqaKMvnNmmmqsbqBo4MJr

@vercel

vercel Bot commented Oct 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
gatherloop-order Ignored Ignored Oct 3, 2026 10:07am UTC
gatherloop-pos Ignored Ignored Oct 3, 2026 10:07am UTC
gatherloop-ui-storybook Ignored Ignored Oct 3, 2026 10:07am UTC

@mnindrazaka
mnindrazaka merged commit fc103ed into main Oct 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants