generated from boboko/starter
86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
{{--
|
|
One cart line. $line is a Lunar\Models\CartLine (iteration var set by
|
|
@each in cart-body). The two forms post through bbk-cart-controller
|
|
(fetch + method spoofing) and the response re-renders cart-body.
|
|
--}}
|
|
@php
|
|
$variant = $line->purchasable;
|
|
$product = $variant?->product;
|
|
$name = $product?->translateAttribute('name') ?? $variant?->sku ?? '—';
|
|
// The variant's own image (falls back to the product's thumbnail
|
|
// internally — see ProductVariant::getThumbnail()) — the specific option
|
|
// the shopper picked, not just the product in general.
|
|
$thumb = $variant?->getThumbnailImage() ?: null;
|
|
$variantLabel = $variant?->getOption();
|
|
@endphp
|
|
|
|
<li class="bbk-cart-item" data-bbk-line-id="{{ $line->id }}">
|
|
<div class="bbk-cart-item-media">
|
|
@if ($thumb)
|
|
<img src="{{ $thumb }}" alt="{{ $name }}" width="72" height="72" loading="lazy">
|
|
@endif
|
|
</div>
|
|
|
|
<div class="bbk-cart-item-detail">
|
|
<p class="bbk-cart-item-title">{{ $name }}</p>
|
|
@if ($variantLabel)
|
|
<p class="bbk-cart-item-variant">{{ $variantLabel }}</p>
|
|
@endif
|
|
<p class="bbk-cart-item-unit">{{ $line->unitPrice?->formatted() }}</p>
|
|
|
|
<form
|
|
class="bbk-cart-qty"
|
|
method="POST"
|
|
action="{{ route('checkout.cart.update', ['locale' => app()->getLocale(), 'line' => $line->id]) }}"
|
|
>
|
|
@csrf
|
|
@method('PATCH')
|
|
<button
|
|
type="button"
|
|
class="bbk-cart-qty-btn"
|
|
data-action="bbk-cart#step"
|
|
data-bbk-cart-dir-param="-1"
|
|
aria-label="{{ __('checkout.cart.decrease') }}"
|
|
>−</button>
|
|
|
|
<input
|
|
type="number"
|
|
name="quantity"
|
|
value="{{ $line->quantity }}"
|
|
min="0"
|
|
inputmode="numeric"
|
|
class="bbk-cart-qty-input"
|
|
data-action="change->bbk-cart#submit"
|
|
data-bbk-cart-confirmed-quantity="{{ $line->quantity }}"
|
|
aria-label="{{ __('checkout.cart.quantity') }}"
|
|
>
|
|
|
|
<button
|
|
type="button"
|
|
class="bbk-cart-qty-btn"
|
|
data-action="bbk-cart#step"
|
|
data-bbk-cart-dir-param="1"
|
|
aria-label="{{ __('checkout.cart.increase') }}"
|
|
>+</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="bbk-cart-item-aside">
|
|
<p class="bbk-cart-item-total">{{ $line->subTotal?->formatted() }}</p>
|
|
|
|
<form
|
|
method="POST"
|
|
action="{{ route('checkout.cart.remove', ['locale' => app()->getLocale(), 'line' => $line->id]) }}"
|
|
data-action="submit->bbk-cart#submit"
|
|
>
|
|
@csrf
|
|
@method('DELETE')
|
|
<button
|
|
type="submit"
|
|
class="bbk-cart-item-remove"
|
|
aria-label="{{ __('checkout.cart.remove') }}"
|
|
>×</button>
|
|
</form>
|
|
</div>
|
|
</li>
|