Skip to content

Resolve cart item availability on retrieval - #534

Merged
mnindrazaka merged 1 commit into
mainfrom
claude/youthful-allen-g9svc8
Sep 17, 2026
Merged

mnindrazaka merged 1 commit into
mainfrom
claude/youthful-allen-g9svc8

Conversation

@mnindrazaka

Copy link
Copy Markdown
Collaborator

Summary

Compute and populate the IsSellable and SellableQuantity fields on cart variants when the cart is retrieved, since these derived fields cannot be read directly from the database.

Changes

  • Added resolveCartAvailability() helper that computes availability for all items in a cart by calling the existing resolveVariantAvailability() function
  • Applied availability resolution to all cart retrieval paths:
    • GetCurrentCart()
    • UpdateCartTable()
    • AddCartItem()
    • UpdateCartItem()
    • RemoveCartItem()
    • ClearCart()
  • Added helper function soldOutVariant() to test suite for creating unavailable variants
  • Added comprehensive test coverage:
    • TestCartUsecase_ResolvesItemAvailability() — validates availability computation for untracked, variant-tracked, product-tracked, and sold-out variants
    • TestCartUsecase_RemoveCartItem_ResolvesRemainingItemAvailability() — ensures remaining items have availability resolved after removal
  • Added e2e test case validating that available cart lines show no "Habis" badge and allow checkout

Implementation Details

The resolveVariantAvailability() function already existed and handles the logic for determining sellability based on tracking type and inventory counts. This change ensures it is consistently applied whenever a cart is returned to the client, making the availability state always accurate and visible in the UI.

https://claude.ai/code/session_01MaYhWTShADmUCUm3AGMbXa

…ld out

IsSellable and SellableQuantity are derived, not stored, so the cart
repository returns them as the Go zero value. CartUsecase never filled
them in the way ProductUsecase and VariantUsecase do, so every cart line
serialised isSellable: false — the order app badged each one "Habis" and
disabled checkout with "Checkout belum tersedia", regardless of whether
the product tracked availability at all.

Resolve availability for each cart item's variant on every cart the use
case returns, and cover the positive case in the order-web e2e suite,
which until now only asserted the badge appears.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MaYhWTShADmUCUm3AGMbXa
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
gatherloop-order Building Building Preview Sep 17, 2026 10:52pm UTC
gatherloop-pos Building Building Preview Sep 17, 2026 10:52pm UTC
gatherloop-ui-storybook Building Building Preview Sep 17, 2026 10:52pm UTC

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