takescake

Site-Wide Shopping Cart: Add Cards from Anywhere

2025-10-05

Site-Wide Shopping Cart: Add Cards from Anywhere

The shopping cart is now site-wide - following you everywhere you browse. Add cards from search results, card detail pages, scanner, or quick search. One cart, everywhere.

What's New

1. Site-Wide Cart Access

The cart is now available on every page:

  • Floating button on all pages (not just scan)
  • Click to navigate to /scan page with full cart
  • Add cards from anywhere on the site

2. Floating Cart Button

A sticky cart button follows you everywhere, always showing:

  • Item count badge (number of cards in cart)
  • Running total (estimated cart value)
  • One-tap access to scroll to your cart

Why This Matters:

  • See your budget in real-time as you shop
  • No scrolling needed to check your total
  • Tap to jump straight to cart for checkout

Visual:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  [3]  Cart       │
│       $47.50     │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
  (Floating at bottom-right)

3. Add to Cart on Card Pages

Every card detail page now has an "šŸ›’ Add to Cart" button:

  • Right next to "Shop on TCGplayer"
  • One-click add to cart
  • Green "āœ“ Added!" feedback
  • Continue browsing, cart persists

4. Quick Card Search

Search by name to instantly add cards to cart - no scanning required:

  • Type card name → see results in under 300ms
  • Prices displayed for each result
  • One-tap add to cart from search results
  • Click card image for full details

Perfect for:

  • Vendor has card laid out, you know the name
  • Adding cards from a want list
  • Building cart from memory/notes
  • Quick checkout when you're in a hurry

5. Add to Cart Everywhere

You can now add cards from multiple places:

  • Card detail pages → "Add to Cart" button
  • Search results → (coming soon!)
  • Quick search → "Add to Cart" on each result
  • Scanner → "Add to Cart" on scanned cards

All routes lead to the same unified cart.

6. Unified Scan Page

Multiple workflows on the same page:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│ Quick Card Search               │
│ [Type card name...]             │
│                                 │
│ [Search Results with Prices]    │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
           ⬇ OR ⬇
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│ Card Scanner                    │
│ [šŸ“· Camera / šŸ“ Upload]         │
│                                 │
│ [Scanned Results with Prices]   │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Choose your method:

  • Search when you know the name
  • Scan when you have the physical card

Real-World Use Cases

1. Minnesota Card Show Shopping

You're at Canterbury Park for the Minnesota Card Show:

Scenario: Walking vendor tables with a budget

  1. Browse vendor's display cases
  2. Search card names as you spot interesting cards
    • "Rhystic Study" → $9.99 → Add to cart
    • "Sol Ring" → $1.50 → Add to cart
  3. Floating cart shows: 2 items - $11.49
  4. Continue shopping across multiple vendors
  5. Floating cart updates as you add more
  6. Check out when ready - all cards in one cart

Key Benefits:

  • Track spending across multiple vendors
  • Don't exceed your budget
  • One place to see all your potential purchases
  • Easy to remove items if you go over budget

2. Bulk Bin Hunting

You're digging through a vendor's bulk commons/uncommons:

Scenario: Finding hidden gems in chaotic bins

  1. Pull out interesting cards
  2. Quick search by name (faster than scanning each)
    • Type "Swords to Plowshares" → $0.50 → Add
    • Type "Lightning Bolt" → $0.75 → Add
    • Type "Brainstorm" → $1.00 → Add
  3. Floating cart shows: 3 items - $2.25
  4. Continue digging through bin
  5. Check cart total before approaching vendor

Key Benefits:

  • Speed over scanning for bulk cards
  • Build cart while vendor is busy with others
  • Have exact total ready for negotiation
  • Easy to adjust quantities before checkout

3. Trading Post Browsing

At an LGS with a trading post/display case:

Scenario: Comparing prices on cards you need

  1. See card in display case
  2. Search by name to check price
    • Store price: $15.00
    • Our price: $12.50 (TCGplayer market)
  3. Decide if store price is fair
  4. Add to cart if you want to track it
  5. Show vendor your cart as your want list

Key Benefits:

  • Price checking without pulling up TCGplayer
  • Build a wishlist to show staff
  • Track cards across multiple stores
  • Have data ready for trade negotiations

4. Commander Deck Building at the Shop

You're at an LGS brewing a new deck:

Scenario: Building from memory + vendor inventory

  1. Know your deck list (saved on phone/in head)
  2. Quick search each card:
    • "Commander's Sphere" → $0.50 → Add
    • "Arcane Signet" → $1.00 → Add
    • "Sol Ring" → $1.50 → Add
  3. Floating cart tracks total as you build
  4. Ask vendor if they have specific cards
  5. Search & add cards they confirm they have
  6. Check out with complete decklist

Key Benefits:

  • Build entire deck list in cart
  • See total before committing
  • Easy to share cart link with friends
  • Can remove cards if over budget

Technical Features

Floating Cart Button

Smart Visibility:

  • Only appears when cart has items
  • Hides when cart is empty (no clutter)
  • Fixed position (always accessible)
  • Z-index ensures it's always on top

Display:

  • Badge → item count (e.g., "3")
  • Label → "Cart"
  • Total → estimated value (e.g., "$47.50")

Interaction:

  • Click → smooth scroll to cart sidebar
  • Hover → lift animation + enhanced shadow
  • Mobile-friendly → large touch target

Styling:

Position: Fixed bottom-right (20px from edges)
Background: Blue gradient (#516dff → #7aa8ff)
Shadow: Glowing blue shadow
Border-radius: Full rounded (pill shape)
Size: Auto-width, comfortable padding

Quick Card Search

Search Performance:

  • Debounced input → waits 300ms after typing stops
  • Minimum 2 characters to trigger search
  • Max 8 results shown (enough to find card, not overwhelming)
  • Parallel pricing fetch → all cards load together

Search API:

GET /api/cards/search?q={query}&size=8

Returns:
- Card name, set, type line
- Card image (local or Scryfall)
- Pricing data (fetched via /api/cards/versions)

Result Display:

  • Grid layout (responsive, 160px min columns)
  • Card image at top
  • Name + set below
  • Price displayed prominently
  • "Add to Cart" button at bottom

Add to Cart Flow:

  1. User clicks "Add to Cart"
  2. Button changes to "āœ“ Added!" with green background
  3. Card added with default non-foil finish
  4. Floating cart updates immediately
  5. Button returns to normal after 2 seconds

Search + Pricing Integration

Data Flow:

1. User types "Rhystic Study"
   ↓
2. /api/cards/search?q=Rhystic+Study
   → Returns: basic card info + image
   ↓
3. For each result: /api/cards/versions?oracle={id}
   → Returns: tcgplayer_id, pricing data
   ↓
4. Merged data shown in search results
   → Card name, set, image, price, "Add to Cart"

Pricing Sources:

  • Primary: TCGcsv nightly cache (fast, offline)
  • Fallback: Scryfall bulk data (when TCGcsv missing)
  • Format: Structured normal/foil pricing
  • Default: Non-foil price shown in search

Mobile Optimization

Responsive Design:

  • Floating button: Bottom-right on all screen sizes
  • Search grid: Stacks to single column on mobile
  • Cart sidebar: Scrolls naturally on small screens
  • Touch targets: All buttons 44px+ for easy tapping

Performance:

  • Debounced search: Prevents excessive API calls
  • Parallel pricing: All cards load simultaneously
  • Image lazy loading: Only loads visible results
  • Cache-friendly: Search results cached 10 minutes

User Workflows

Workflow 1: Quick Search → Cart → Checkout

Steps:

  1. Open /scan page
  2. Type card name in search box
  3. See results with prices
  4. Click "Add to Cart" for desired cards
  5. Floating button shows running total
  6. Repeat for all cards
  7. Click floating button to scroll to cart
  8. Review cart, toggle foil if needed
  9. Click "Buy on TCGplayer" for checkout

Time: ~30 seconds to add 5-10 cards

Workflow 2: Scan + Search Combo

Steps:

  1. Scan cards you're holding
  2. Add scanned cards to cart
  3. Search cards vendor mentions they have
  4. Add searched cards to cart
  5. Floating button tracks combined total
  6. Review mixed cart before checkout

Why This Works:

  • Scan for cards in hand
  • Search for cards in vendor's case
  • One unified cart for everything

Workflow 3: Build Want List at Trade Show

Steps:

  1. Walk entire show once
  2. Search & add every card you're interested in
  3. Floating button shows total cost of want list
  4. Prioritize which vendors to revisit
  5. Remove expensive cards to fit budget
  6. Revisit vendors for final purchases

Key Insight:

  • Cart becomes your dynamic shopping list
  • Floating total = instant budget check
  • Easy to adjust on the fly

Developer Notes

Component Structure

FloatingCartButton.tsx:

  • Reads useScanCart() context
  • Shows only when totalCount > 0
  • Accepts onClick callback for scroll behavior
  • Pure presentational component

QuickCardSearch.tsx:

  • Manages search state internally
  • Debounced API calls (300ms)
  • Parallel pricing fetch per result
  • Uses useScanCart() to add items
  • Handles navigation to card detail pages

Modified: app/scan/page.tsx:

  • Now a 'use client' component
  • Renders <FloatingCartButton> at top level
  • Renders <QuickCardSearch> above scanner
  • Adds data-scan-cart attribute for scroll target
  • Handles scroll-to-cart callback

API Dependencies

Required Endpoints:

  1. GET /api/cards/search

    • Basic card search
    • Returns: name, set, image, oracle_id
    • Used by QuickCardSearch
  2. GET /api/cards/versions

    • Pricing data for specific card
    • Returns: tcgplayer_id, pricing, tcgcsv
    • Used to enrich search results

Both endpoints already exist - no new APIs needed!

State Management

Cart State:

  • ScanCartContext handles all cart operations
  • addItem() adds cards from search or scan
  • setFoil() toggles finish after adding
  • totalCount and estimatedTotal for floating button

Search State:

  • Local component state (no global context needed)
  • query → input value
  • results → search results with pricing
  • isSearching → loading state
  • lastAddedId → "Added!" feedback state

Performance Considerations

Search Debouncing:

  • Prevents API spam during fast typing
  • 300ms delay balances responsiveness + efficiency
  • Cleans up timeout on unmount

Parallel Pricing:

  • All cards fetch pricing simultaneously
  • Doesn't block on slow requests
  • Handles failures gracefully (card shows without price)

Caching:

  • Search API caches results 10 minutes
  • Pricing API uses nightly TCGcsv cache
  • No unnecessary network calls

Future Enhancements

Short Term

  • Voice search → "Add Rhystic Study" (hands-free at shows)
  • Barcode scanner → scan set codes for quick add
  • Recent searches → quickly re-add common cards

Medium Term

  • Want list import → paste deck list, auto-search all cards
  • Vendor notes → track which vendor had which cards
  • Price alerts → "Sol Ring now $1.00 (was $1.50)"

Long Term

  • Multi-vendor carts → separate carts per vendor
  • Show directory → Minnesota Card Show vendor map
  • Trade calculator → value your trades in cart

Testing Checklist

When testing the new trade show features:

  • Floating button appears after adding first item
  • Floating button shows correct count
  • Floating button shows correct total
  • Clicking floating button scrolls to cart
  • Floating button hides when cart is empty
  • Quick search returns results within 300ms
  • Search results show pricing when available
  • "Add to Cart" changes to "āœ“ Added!" briefly
  • Cards added from search appear in cart
  • Cart total updates when adding from search
  • Search + scan both add to same cart
  • Mobile layout works (button + search responsive)
  • Keyboard navigation works in search input

Conclusion

The floating cart button and quick card search transform the scan page into a complete trade show shopping tool:

āœ… Always see your budget (floating total)
āœ… Add cards instantly (search by name)
āœ… No scrolling needed (floating button)
āœ… Unified workflow (scan + search → same cart)
āœ… Mobile-friendly (works at shows on phone)

Perfect for:

  • Minnesota Card Show (October 5, 2025)
  • LGS browsing sessions
  • Vendor table shopping
  • Bulk bin hunting
  • Trade negotiations

This update makes building your cart as fast as finding the cards - exactly what you need when shopping at crowded card shows where speed matters.


Updated: October 5, 2025
Feature shipped for Minnesota Card Show

Related Posts