{# Product Card ============ A versatile product card component for e-commerce listings. Supports multiple sizes, badges, ratings, and quick actions. Parameters: - product_var: Alpine.js variable name for the product object (default: 'product') - size: 'sm' | 'md' | 'lg' (default: 'md') - show_rating: Show star rating (default: true) - show_quick_add: Show quick add to cart button (default: true) - show_wishlist: Show wishlist heart icon (default: true) - show_store: Show store name for marketplace (default: false) - add_to_cart_action: Alpine.js action for add to cart (default: 'addToCart(product)') - wishlist_action: Alpine.js action for wishlist toggle (default: 'toggleWishlist(product)') - product_url_field: Field name for product URL (default: 'url') - image_field: Field name for image URL (default: 'image_url') - title_field: Field name for product title (default: 'name') - price_field: Field name for price (default: 'price') - sale_price_field: Field name for sale price (default: 'sale_price') - rating_field: Field name for rating (default: 'rating') - review_count_field: Field name for review count (default: 'review_count') - stock_field: Field name for stock quantity (default: 'stock') - store_field: Field name for store name (default: 'store_name') Expected product object structure: { id: number, name: string, url: string, image_url: string, price: number, sale_price: number | null, rating: number (0-5), review_count: number, stock: number, is_new: boolean, store_name: string (optional) } Usage: {% from 'shared/macros/storefront/product-card.html' import product_card %} {{ product_card() }} {# With custom settings #} {{ product_card(product_var='featuredProduct', size='lg', show_store=true) }} #} {% macro product_card( product_var='product', size='md', show_rating=true, show_quick_add=true, show_wishlist=true, show_store=false, add_to_cart_action='addToCart(product)', wishlist_action='toggleWishlist(product)', product_url_field='url', image_field='image_url', title_field='name', price_field='price', sale_price_field='sale_price', rating_field='rating', review_count_field='review_count', stock_field='stock', store_field='store_name' ) %} {% set sizes = { 'sm': { 'card': 'max-w-[200px]', 'image': 'h-32', 'title': 'text-sm', 'price': 'text-sm', 'badge': 'text-xs px-1.5 py-0.5', 'btn': 'text-xs px-2 py-1', 'icon': 'w-4 h-4', 'rating': 'w-3 h-3' }, 'md': { 'card': 'max-w-[280px]', 'image': 'h-48', 'title': 'text-base', 'price': 'text-base', 'badge': 'text-xs px-2 py-1', 'btn': 'text-sm px-3 py-2', 'icon': 'w-5 h-5', 'rating': 'w-4 h-4' }, 'lg': { 'card': 'max-w-[360px]', 'image': 'h-64', 'title': 'text-lg', 'price': 'text-lg', 'badge': 'text-sm px-2.5 py-1', 'btn': 'text-base px-4 py-2.5', 'icon': 'w-6 h-6', 'rating': 'w-5 h-5' } } %} {% set s = sizes[size] %}