Fix gift card not updating checkout sidebar - #103
Conversation
The sidebar cartKey only included cart.id, cart.total, and cart.total_quantity — none of which change when a gift card is applied. This caused the useEffect to skip the setSummaryContent call, so the sidebar never reflected the gift card until the next unrelated cart refresh (e.g. address save). Add cart.gift_card_total to the cartKey so the sidebar re-renders immediately when a gift card is applied or removed. Also add cursor-pointer to the discount/gift-card remove buttons. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughUpdated checkout sidebar key to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // Track cart key for sidebar updates | ||
| const cartKey = cart | ||
| ? `${cart.id}-${cart.total}-${cart.total_quantity}` | ||
| ? `${cart.id}-${cart.total}-${cart.total_quantity}-${cart.gift_card_total ?? ""}` |
There was a problem hiding this comment.
its better to use amount due which will work with both gift cards and store credits
Replace gift_card_total with amount_due so the checkout sidebar refreshes when either gift cards or store credits are applied. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
cartKeyused to gate sidebar updates only trackedcart.totalandcart.total_quantity, which don't change when a gift card is applied. Addedcart.gift_card_totalto the key so the sidebar updates immediately.cursor-pointerto discount code and gift card remove (✕) buttons in checkout.Note:
amount_duedisplay in the Summary component depends on the backend returning a correctamount_duevalue distinct fromtotal— currently the API returns them equal, so the "Amount due" row doesn't appear. This is a backend issue tracked separately.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Style