跳转到主要内容 跳转到导航 跳转到搜索 跳转到页脚

🛒 Shopping Cart

Cart management, item controls, pricing displays, and checkout flow components

🎭 Component Demonstrations

Interactive shopping cart components and checkout experiences

🗂️ Cart Drawer

Shopping Cart

🛒

Your cart is empty

Total:

🛍️ Full Page Shopping Cart

Your Shopping Cart

Have a coupon code?

Try "SAVE10" for 10% off

Order Summary

Subtotal:
Discount:
Shipping:
Total:

Secure Checkout

SSL 256-bit Verified

🏷️ Mini Cart Widget

Quick Cart View

Wireless Headphones

1 × $79.99

Bluetooth Speaker

2 × $149.99

Total:

❤️ Wishlist Component

My Wishlist

💝

Your wishlist is empty

📧 Cart Recovery Components

Exit Intent Popup

🚪

Wait! Don't leave empty-handed

Complete your purchase and get 10% off

Limited Time Offer

Special Discount Expires Soon!

Hours
Minutes
Seconds

🎁 Enhanced Cart Item Features

💾 Saved for Later

Recently Removed:

🚚 Free Shipping Progress

Add $ more for FREE shipping! ✓ You qualify for FREE shipping! $ / $
🚚

💰 Enhanced Order Summary

Order Summary ( items)

Subtotal
Estimated Tax
Shipping
Discount
Gift Card
Loyalty Points
Total

Promo Code

Try "SAVE20" for 20% off

Gift Card / Store Credit

Loyalty Points

points available

Value: $

Order Notes

🎁 Bundle & Save

🛒 Empty Cart States

🛒

Your cart is empty

Looks like you haven't added anything to your cart yet.

💡

Need some inspiration?

Check out these popular items

💲 Quantity Discounts

Bulk Pricing Calculator

Unit Price:
Discounted Price:
Total:
You save $!

📝 Usage Examples

Code snippets for implementing shopping cart components in your Hyvä theme

Basic Cart Drawer with Alpine.js

<div x-data="{ showCart: false, cartItems: [] }">
    <button @click="showCart = true" class="bg-blue-600 text-white px-4 py-2 rounded">
        Open Cart (<span x-text="cartItems.length"></span>)
    </button>
    
    <div x-show="showCart" 
         x-transition:enter="transition ease-out duration-300"
         x-transition:enter-start="transform translate-x-full"
         x-transition:enter-end="transform translate-x-0"
         class="fixed right-0 top-0 h-full w-96 bg-white shadow-xl z-50">
        <!-- Cart content -->
    </div>
</div>

Cart Item Quantity Management

<div class="flex items-center space-x-2">
    <button @click="updateQuantity(item.id, item.qty - 1)" 
            class="w-8 h-8 bg-gray-200 rounded hover:bg-gray-300">-</button>
    <span x-text="item.qty" class="w-8 text-center"></span>
    <button @click="updateQuantity(item.id, item.qty + 1)" 
            class="w-8 h-8 bg-gray-200 rounded hover:bg-gray-300">+</button>
</div>

<script>
function updateQuantity(id, qty) {
    const item = this.cartItems.find(item => item.id === id);
    if (item) {
        item.qty = Math.max(0, qty);
        if (item.qty === 0) {
            this.removeItem(id);
        }
    }
}
</script>

Pricing Calculation with Discounts

<div x-data="{ 
    subtotal: 299.97, 
    discount: 0, 
    shipping: 15.99,
    get total() { 
        return this.subtotal - this.discount + this.shipping; 
    },
    applyCoupon(code) {
        if (code.toLowerCase() === 'save10') {
            this.discount = this.subtotal * 0.1;
        }
    }
}">
    <div class="space-y-2">
        <div class="flex justify-between">
            <span>Subtotal:</span>
            <span x-text="'$' + subtotal.toFixed(2)"></span>
        </div>
        <div x-show="discount > 0" class="flex justify-between text-green-600">
            <span>Discount:</span>
            <span x-text="'-$' + discount.toFixed(2)"></span>
        </div>
        <div class="flex justify-between font-bold">
            <span>Total:</span>
            <span x-text="'$' + total.toFixed(2)"></span>
        </div>
    </div>
</div>

⚡ Performance & Accessibility

Best practices for optimized and accessible shopping cart experiences

🎯

Cart Accessibility

Implement ARIA live regions for cart updates, screen reader announcements for item additions/removals, proper focus management in cart drawers, and keyboard navigation support for all cart interactions.

Performance Optimization

Optimize cart state management with efficient Alpine.js reactivity, minimize DOM updates during quantity changes, implement debounced API calls for cart modifications, and use CSS transforms for smooth animations.

📱

Mobile-Friendly Cart Interactions

Design touch-friendly quantity controls with adequate tap targets, implement swipe gestures for item removal, ensure cart drawers work seamlessly on mobile devices, and provide clear visual feedback for all touch interactions.

💾

Data Persistence and Cart State Management

Maintain cart state across page reloads using localStorage integration, synchronize cart data with backend APIs, implement automatic cart recovery for session timeouts, and provide offline cart functionality where possible.