Product card
The card of the product lists: the picture, the badges, the category, the name, the rating and the price. It has no buttons; you put yours in its four places (the corner, the picture's foot, beside the price, the card's foot).
zb:shop.product-card zubazar/ui-pro
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
One card
The card takes an Zubazar\Commerce\Data\Product and fills the width of its box.
<zb:shop.product-card :product="$product" />
A product with options and low stock
The product's data decides what the card shows: the sale, new and stock badges, and with a low stock the number left.
<zb:shop.product-card :product="$tshirt" />
| Prop | Values |
|---|---|
old_price | Higher than the price: the discount badge (-20%) and the old price struck through |
new | true: the "New" badge |
stock | From 1 to 5: "Only 3 left" under the name |
rating, reviews | The stars, the score and the number of reviews (zb:shop.rating) |
category | The category link above the name |
visual | shape and hue: the card's picture (zb:shop.product-visual) |
Your buttons in its places
The card is free of content: you give the buttons and their words ("Add to cart", "Quick view"). corner (round icons in the corner: zb:shop.icon-button), overlay (the picture's foot), action (beside the price) and footer (the card's foot). The corner and the picture's foot show under a mouse (always on a touch screen; always with reveal="always"). The theme's lists draw the card with your card view: commerce.card.view.
<zb:shop.product-card :product="$product">
<zb:slot:corner>
<zb:shop.icon-button icon="eye" label="Quick view" data-zb-shop-quick-view="{{ $product->slug }}" />
</zb:slot:corner>
<zb:slot:overlay>
<zb:button class="w-full">Add to cart</zb:button>
</zb:slot:overlay>
</zb:shop.product-card>
<zb:shop.product-card :product="$product" hover="zoom backdrop" hover-text="Look">
<zb:slot:action><zb:button size="sm">Add</zb:button></zb:slot:action>
</zb:shop.product-card>
A scrolling row
The card adds class to its own box; here the cards have a fixed width, stand side by side and the row scrolls sideways.
<div class="flex snap-x gap-4 overflow-x-auto pb-2">
@foreach ($recentlyViewed as $product)
<zb:shop.product-card :product="$product" key-prefix="recent" class="w-56 flex-none snap-start" />
@endforeach
</div>
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
product | — | — | The product shown (Zubazar\Commerce\Data\Product); required |
key-prefix | — | card | The key prefix of the card's Livewire component; keeps two lists apart when the same product is in both |
aspect | — | null | The picture's shape: default (4:3.6) · square (1:1) · portrait (3:4, a model photo) · tall (4:5); null: commerce.card.image_aspect, else the store's (commerce.image_aspect) |
hover | — | null | Under a mouse: zoom · swap (the second photo; for a product without photos, the drawing's second angle with placeholder_views 3) · backdrop (the picture dims) · none; several with spaces: "swap backdrop"; null: commerce.card.hover (zoom) |
hover-text | — | null | A word in the middle of the picture under a mouse ("Quick look"); null: commerce.card.hover_text (none) |
reveal | — | hover | When the corner and the picture's foot show: hover (under a mouse or the keyboard's focus; always on a touch screen) · always. One pressed (aria-pressed) or just added (data-added) stays |
price-line | — | null | The price line: stacked (the old price above; a row's prices on one line) · inline (side by side); null: commerce.card.price |
out-of-stock | — | null | The "Out of stock" badge; null: at a stock of 0 (pass false for a product sold on a quote) |
layout | — | grid | grid (the picture above) · list (the picture on the left, the name, rating, short description and price beside it; under 28rem wide it stands up again). Your card view passes it on with `:layout="$layout ?? 'grid'"` |
Slots: corner: round icons in the picture's corner (zb:shop.icon-button: label, icon, pressed, href; the label becomes a tip on its left). overlay: the picture's foot, centred (class="w-full" for the whole width). action: beside the price. footer: under the price line, always shown. The kit's hooks work on your buttons: data-zb-shop-add-to-cart ("Added" and the flight to the cart, cart-updated), data-zb-shop-quick-view, data-zb-shop-favorite.
Developer notes
- The theme's showcases, product lists and related products draw the card with your card view:
commerce.card.view(the view gets$product,$keyPrefix,$class); without it the kit's card without buttons. - The prices of a row of cards stand on one line: the name always keeps two lines, and the old price has its own line above the price (empty without a discount).
- For all of the store's cards:
config/zubazar-ui-pro.php›commerce.card(view,hover,hover_text,image_aspect,price), orSHOP_CARD_HOVER,SHOP_CARD_HOVER_TEXT,SHOP_CARD_IMAGE_ASPECT. The gallery may stay 3:4 while the cards are 4:5:SHOP_CARD_IMAGE_ASPECT=tall. - With reduced motion the card's effects stay still.
- The card uses the theme's corner and surface settings.
- With a stock of five or fewer, a line under the name says how many are left.
- The same product can be in two lists on a page: when each list sets its own
key-prefix, the keys of the cards' Livewire components never clash.