command: sed -n '1,300p' app/Livewire/Storefront/Checkout/Show.php; sed -n '1,360p' resources/views/livewire/storefront/checkout/show.blade.php

Show.php

stdout:
<?php

namespace App\Livewire\Storefront\Checkout;

use App\Enums\CheckoutStatus;
use App\Enums\PaymentMethod;
use App\Exceptions\InvalidDiscountException;
use App\Models\Checkout as CheckoutModel;
use App\Models\CustomerAddress;
use App\Services\CheckoutService;
use App\Services\DiscountService;
use App\Services\PaymentService;
use App\Services\PricingEngine;
use App\Services\ShippingCalculator;
use Carbon\Carbon;
use Livewire\Component;
use Throwable;

class Show extends Component
{
    public CheckoutModel $checkout;

    public string $email = '';

    /** @var array<string, string> */
    public array $shippingAddress = [
        'first_name' => '',
        'last_name' => '',
        'address1' => '',
        'address2' => '',
        'city' => '',
        'state' => '',
        'country_code' => 'DE',
        'postal_code' => '',
        'phone' => '',
    ];

    /** @var array<string, string> */
    public array $billingAddress = [
        'first_name' => '',
        'last_name' => '',
        'address1' => '',
        'address2' => '',
        'city' => '',
        'state' => '',
        'country_code' => 'DE',
        'postal_code' => '',
        'phone' => '',
    ];

    public bool $billingSameAsShipping = true;

    public ?int $savedAddressId = null;

    public ?int $shippingRateId = null;

    public string $paymentMethod = PaymentMethod::CreditCard->value;

    public string $cardNumber = '4242424242424242';

    public string $cardholderName = '';

    public string $cardExpiry = '';

    public string $cardCvc = '';

    public string $discountCode = '';

    public string $message = '';

    public bool $processing = false;

    public int $activeStep = 1;

    public bool $showOrderSummary = false;

    public function mount(int $checkoutId): void
    {
        $this->checkout = CheckoutModel::query()
            ->with(['cart.lines.variant.product.media', 'shippingRate'])
            ->findOrFail($checkoutId);

        $customerId = auth('customer')->id();
        $sessionCartIds = array_filter([
            session('cart_id'),
            session('cart_id_'.app('current_store')->getKey()),
        ]);

        abort_unless(
            ($customerId !== null && (int) $this->checkout->customer_id === (int) $customerId)
                || ($customerId === null && in_array($this->checkout->cart_id, $sessionCartIds, true)),
            404,
        );

        $this->email = (string) $this->checkout->email;
        $this->discountCode = (string) ($this->checkout->discount_code ?? '');
        $this->shippingRateId = $this->checkout->shipping_rate_id;
        $this->paymentMethod = (string) ($this->checkout->payment_method ?? PaymentMethod::CreditCard->value);

        if ($this->checkout->shipping_address_json !== null) {
            $this->shippingAddress = array_merge($this->shippingAddress, $this->checkout->shipping_address_json);
        }

        if ($this->checkout->billing_address_json !== null) {
            $this->billingAddress = array_merge($this->billingAddress, $this->checkout->billing_address_json);
            $this->billingSameAsShipping = $this->billingAddress === $this->shippingAddress;
        }

        $this->activeStep = match ($this->checkout->status) {
            CheckoutStatus::Started => 1,
            CheckoutStatus::Addressed => 3,
            CheckoutStatus::ShippingSelected, CheckoutStatus::PaymentSelected, CheckoutStatus::PaymentPending, CheckoutStatus::Completed => 4,
            default => 1,
        };
    }

    public function saveContact(): void
    {
        $this->validate([
            'email' => ['required', 'email', 'max:255'],
        ], [
            'email.required' => 'Enter an email address to receive your order confirmation.',
        ]);

        $this->checkout->update(['email' => $this->email]);
        $this->checkout->refresh();
        $this->message = 'Contact information saved.';
        $this->activeStep = 2;
    }

    public function saveAddress(CheckoutService $checkouts, PricingEngine $pricing): void
    {
        $this->normalizeAddresses();

        $rules = [
            'email' => ['required', 'email', 'max:255'],
            ...$this->addressRules('shippingAddress'),
        ];

        if (! $this->billingSameAsShipping) {
            $rules = [...$rules, ...$this->addressRules('billingAddress')];
        }

        $this->validate($rules);

        $this->checkout->update(['email' => $this->email]);
        $this->checkout = $checkouts->setAddress(
            $this->checkout->refresh(),
            $this->shippingAddress,
            $this->billingAddress,
            $this->billingSameAsShipping,
        );

        if ($this->requiresShipping()) {
            $this->checkout->update([
                'shipping_rate_id' => null,
                'shipping_method_id' => null,
                'status' => CheckoutStatus::Addressed,
            ]);
            $this->checkout = $this->checkout->refresh();
            $pricing->calculate($this->checkout);
            $this->checkout = $this->checkout->refresh();
            $this->shippingRateId = null;
            $this->activeStep = 3;
        } else {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, 0);
            $this->shippingRateId = null;
            $this->activeStep = 4;
        }

        $this->message = 'Address saved.';
    }

    public function selectSavedAddress(int|string|null $addressId): void
    {
        $customerId = auth('customer')->id();

        if ($customerId === null || $addressId === null || $addressId === '') {
            $this->savedAddressId = null;

            return;
        }

        $address = CustomerAddress::query()
            ->whereKey((int) $addressId)
            ->where('customer_id', $customerId)
            ->firstOrFail();

        $this->savedAddressId = $address->getKey();
        $this->shippingAddress = array_merge($this->shippingAddress, $address->address_json ?? []);

        if ($this->billingSameAsShipping) {
            $this->billingAddress = $this->shippingAddress;
        }
    }

    public function updatedBillingSameAsShipping(bool $same): void
    {
        if ($same) {
            $this->billingAddress = $this->shippingAddress;
        }
    }

    public function chooseShipping(CheckoutService $checkouts): void
    {
        if (! $this->requiresShipping()) {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, 0);
            $this->activeStep = 4;

            return;
        }

        $this->validate(['shippingRateId' => ['required', 'integer']]);

        try {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, $this->shippingRateId);
            $this->message = 'Shipping method saved.';
            $this->activeStep = 4;
        } catch (Throwable $exception) {
            $this->addError('shippingRateId', $exception->getMessage());
        }
    }

    public function applyDiscount(DiscountService $discounts, PricingEngine $pricing): void
    {
        $this->validate(['discountCode' => ['required', 'string', 'max:64']]);

        try {
            $code = trim($this->discountCode);
            $discount = $discounts->validate($code, app('current_store'), $this->checkout->cart);
            $this->checkout->cart->update(['discount_code' => $discount->code]);
            $this->checkout->update(['discount_code' => $discount->code]);
            $this->checkout = $this->checkout->refresh();
            $pricing->calculate($this->checkout);
            $this->checkout = $this->checkout->refresh();
            $this->checkout->load(['cart.lines.variant.product.media', 'shippingRate']);
            $this->discountCode = $discount->code;
            $this->message = 'Discount applied.';
        } catch (InvalidDiscountException $exception) {
            $this->addError('discountCode', $exception->getMessage());
        }
    }

    public function removeDiscount(PricingEngine $pricing): void
    {
        $this->checkout->cart->update(['discount_code' => null]);
        $this->checkout->update(['discount_code' => null]);
        $this->checkout = $this->checkout->refresh();
        $pricing->calculate($this->checkout);
        $this->checkout = $this->checkout->refresh();
        $this->checkout->load(['cart.lines.variant.product.media', 'shippingRate']);
        $this->discountCode = '';
        $this->message = 'Discount removed.';
        $this->resetValidation('discountCode');
    }

    public function pay(CheckoutService $checkouts, PaymentService $payments): void
    {
        if ($this->processing) {
            return;
        }

        $this->cardNumber = preg_replace('/\D+/', '', $this->cardNumber) ?? '';
        $rules = [
            'email' => ['required', 'email', 'max:255'],
            'paymentMethod' => ['required', 'in:credit_card,paypal,bank_transfer'],
        ];

        if ($this->paymentMethod === PaymentMethod::CreditCard->value) {
            $rules = [
                ...$rules,
                'cardNumber' => ['required', 'digits:16'],
                'cardholderName' => ['required', 'string', 'max:255'],
                'cardExpiry' => ['required', 'regex:/^(0[1-9]|1[0-2])\/\d{2}$/'],
                'cardCvc' => ['required', 'digits_between:3,4'],
            ];
        }

        $this->validate($rules);

        if ($this->paymentMethod === PaymentMethod::CreditCard->value && ! $this->cardExpiryIsFuture()) {
            $this->addError('cardExpiry', 'Enter a future expiry date in MM/YY format.');

            return;
        }

        if ($this->checkout->shipping_address_json === null) {
            $this->addError('payment', 'Save your shipping address before placing the order.');
            $this->activeStep = 2;

            return;
        }

        if ($this->requiresShipping() && $this->checkout->shipping_rate_id === null) {
            $this->addError('payment', 'Choose a shipping method before placing the order.');
            $this->activeStep = 3;

            return;
        }

Secure checkout

Complete your order

Your information is used only to process and deliver this order.

        <button type="button" wire:click="toggleOrderSummary" class="flex min-h-14 w-full items-center justify-between rounded-xl border border-zinc-200 bg-zinc-50 px-4 py-3 text-left dark:border-zinc-800 dark:bg-zinc-900" aria-controls="mobile-order-summary" aria-expanded="{{ $showOrderSummary ? 'true' : 'false' }}">

                {{ $showOrderSummary ? 'Hide order summary' : 'Show order summary' }}
                {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}

            {{ $showOrderSummary ? '⌃' : '⌄' }}
        </button>

                    <button type="button" wire:click="setActiveStep(1)" class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 dark:focus:ring-offset-zinc-900" aria-controls="checkout-contact-panel" aria-expanded="{{ $activeStep === 1 ? 'true' : 'false' }}">
                         1 ? 'bg-green-600 text-white' : 'bg-blue-600 text-white' }} text-sm font-bold">{{ $activeStep > 1 ? '✓' : '1' }}

                            Contact information
                            @if ($activeStep > 1)
                                {{ $checkout->email }}
                            @endif

                    </button>
                    @if ($activeStep > 1)
                        <button type="button" wire:click="setActiveStep(1)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 1)
                    <form id="checkout-contact-panel" wire:submit="saveContact" class="space-y-4 p-5 sm:p-6">

                            Email address *
                            <input id="checkout-email" type="email" wire:model.blur="email" autocomplete="email" required aria-describedby="checkout-email-help checkout-email-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 text-zinc-950 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">

We’ll send your order confirmation here.

                            @error('email')

{{ $message }}

                            @enderror

Already have an account? Log in

                        <button type="submit" wire:loading.attr="disabled" class="inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                            Continue to shipping address
                            Saving…
                        </button>
                    </form>
                @endif

                    <button type="button" wire:click="setActiveStep(2)" @disabled($activeStep < 2) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-address-panel" aria-expanded="{{ $activeStep === 2 ? 'true' : 'false' }}">
                        shipping_address_json !== null ? 'bg-green-600 text-white' : 'bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300' }} text-sm font-bold">{{ $checkout->shipping_address_json !== null && $activeStep !== 2 ? '✓' : '2' }}

                            Shipping address
                            @if ($checkout->shipping_address_json !== null && $activeStep !== 2)
                                {{ $shippingAddress['city'] }}, {{ $shippingAddress['country_code'] }}
                            @endif

                    </button>
                    @if ($checkout->shipping_address_json !== null && $activeStep !== 2)
                        <button type="button" wire:click="setActiveStep(2)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 2)
                    <form id="checkout-address-panel" wire:submit="saveAddress" class="space-y-6 p-5 sm:p-6">
                        @if ($savedAddresses->isNotEmpty())

                                Use a saved address
                                <select id="saved-address" wire:model.live="savedAddressId" wire:change="selectSavedAddress($event.target.value)" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 text-zinc-950 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    <option value="">Use a new address</option>
                                    @foreach ($savedAddresses as $address)
                                        <option wire:key="saved-address-{{ $address->id }}" value="{{ $address->id }}">{{ $address->label ?: 'Saved address' }}{{ $address->is_default ? ' (default)' : '' }}</option>
                                    @endforeach
                                </select>

                        @endif

                        <fieldset>
                            <legend class="text-base font-semibold text-zinc-950 dark:text-white">Shipping address</legend>

                                    First name *
                                    <input id="shipping-first-name" type="text" wire:model.blur="shippingAddress.first_name" autocomplete="given-name" required aria-describedby="shipping-first-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.first_name')
{{ $message }}
@enderror

                                    Last name *
                                    <input id="shipping-last-name" type="text" wire:model.blur="shippingAddress.last_name" autocomplete="family-name" required aria-describedby="shipping-last-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.last_name')
{{ $message }}
@enderror

                                    Address line 1 *
                                    <input id="shipping-address1" type="text" wire:model.blur="shippingAddress.address1" autocomplete="address-line1" required aria-describedby="shipping-address1-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.address1')
{{ $message }}
@enderror

                                    Address line 2 (optional)
                                    <input id="shipping-address2" type="text" wire:model.blur="shippingAddress.address2" autocomplete="address-line2" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">

                                    City *
                                    <input id="shipping-city" type="text" wire:model.blur="shippingAddress.city" autocomplete="address-level2" required aria-describedby="shipping-city-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.city')
{{ $message }}
@enderror

                                    State / province *
                                    <input id="shipping-state" type="text" wire:model.blur="shippingAddress.state" autocomplete="address-level1" required aria-describedby="shipping-state-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.state')
{{ $message }}
@enderror

                                    Postal code *
                                    <input id="shipping-postal-code" type="text" wire:model.blur="shippingAddress.postal_code" autocomplete="postal-code" required aria-describedby="shipping-postal-code-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.postal_code')
{{ $message }}
@enderror

                                    Country *
                                    <select id="shipping-country" wire:model.blur="shippingAddress.country_code" autocomplete="country" required aria-describedby="shipping-country-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        <option value="DE">Germany</option>
                                        <option value="AT">Austria</option>
                                        <option value="CH">Switzerland</option>
                                        <option value="GB">United Kingdom</option>
                                        <option value="US">United States</option>
                                    </select>
                                    @error('shippingAddress.country_code')
{{ $message }}
@enderror

                                    Phone (optional)
                                    <input id="shipping-phone" type="tel" wire:model.blur="shippingAddress.phone" autocomplete="tel" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">

                        </fieldset>

                            <input type="checkbox" wire:model.live="billingSameAsShipping" class="mt-1 h-4 w-4 rounded border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700" />
                            Billing address is the same as shipping

                        @if (! $billingSameAsShipping)
                            <fieldset>
                                <legend class="text-base font-semibold text-zinc-950 dark:text-white">Billing address</legend>

                                        First name *
                                        <input id="billing-first-name" type="text" wire:model.blur="billingAddress.first_name" autocomplete="billing given-name" required aria-describedby="billing-first-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.first_name')
{{ $message }}
@enderror

                                        Last name *
                                        <input id="billing-last-name" type="text" wire:model.blur="billingAddress.last_name" autocomplete="billing family-name" required aria-describedby="billing-last-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.last_name')
{{ $message }}
@enderror

                                        Address line 1 *
                                        <input id="billing-address1" type="text" wire:model.blur="billingAddress.address1" autocomplete="billing address-line1" required aria-describedby="billing-address1-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.address1')
{{ $message }}
@enderror

                                        Address line 2 (optional)
                                        <input id="billing-address2" type="text" wire:model.blur="billingAddress.address2" autocomplete="billing address-line2" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">

                                        City *
                                        <input id="billing-city" type="text" wire:model.blur="billingAddress.city" autocomplete="billing address-level2" required aria-describedby="billing-city-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.city')
{{ $message }}
@enderror

                                        State / province *
                                        <input id="billing-state" type="text" wire:model.blur="billingAddress.state" autocomplete="billing address-level1" required aria-describedby="billing-state-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.state')
{{ $message }}
@enderror

                                        Postal code *
                                        <input id="billing-postal-code" type="text" wire:model.blur="billingAddress.postal_code" autocomplete="billing postal-code" required aria-describedby="billing-postal-code-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.postal_code')
{{ $message }}
@enderror

                                        Country *
                                        <select id="billing-country" wire:model.blur="billingAddress.country_code" autocomplete="billing country" required aria-describedby="billing-country-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                            <option value="DE">Germany</option>
                                            <option value="AT">Austria</option>
                                            <option value="CH">Switzerland</option>
                                            <option value="GB">United Kingdom</option>
                                            <option value="US">United States</option>
                                        </select>
                                        @error('billingAddress.country_code')
{{ $message }}
@enderror

                            </fieldset>
                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                            Continue to shipping
                            Saving…
                        </button>
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your contact information first.

                @endif

                    <button type="button" wire:click="setActiveStep(3)" @disabled($activeStep < 3) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-shipping-panel" aria-expanded="{{ $activeStep === 3 ? 'true' : 'false' }}">
                        shipping_rate_id !== null || ! $this->requiresShipping() ? 'bg-green-600 text-white' : 'bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300' }} text-sm font-bold">{{ ($checkout->shipping_rate_id !== null || ! $this->requiresShipping()) && $activeStep !== 3 ? '✓' : '3' }}

                            Shipping method
                            @if (! $this->requiresShipping())
                                No shipping required
                            @elseif ($checkout->shippingRate && $activeStep !== 3)
                                {{ $checkout->shippingRate->name }}
                            @endif

                    </button>
                    @if ($activeStep > 3 && $this->requiresShipping())
                        <button type="button" wire:click="setActiveStep(3)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 3)
                    <form id="checkout-shipping-panel" wire:submit="chooseShipping" class="p-5 sm:p-6">
                        @if ($rates->isEmpty())

No shipping methods are available for your address.

Please verify your address or contact us.

                        @else
                            <fieldset>
                                <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a shipping method *</legend>

                                    @foreach ($rates as $rate)
                                        id }}" class="flex cursor-pointer items-center gap-4 rounded-xl border p-4 transition has-[:checked]:border-blue-600 has-[:checked]:bg-blue-50 dark:has-[:checked]:bg-blue-950/20 {{ (int) $shippingRateId === (int) $rate->id ? 'border-blue-600 bg-blue-50 dark:bg-blue-950/20' : 'border-zinc-200 dark:border-zinc-700' }}">
                                            <input id="shipping-rate-{{ $rate->id }}" type="radio" wire:model="shippingRateId" value="{{ $rate->id }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">

                                                {{ $rate->name }}

                                                    @if ($rate->estimated_days_min && $rate->estimated_days_max)
                                                        {{ $rate->estimated_days_min }}–{{ $rate->estimated_days_max }} business days
                                                    @else
                                                        Delivery time shown at dispatch
                                                    @endif

                                            {{ $this->formatMoney($rate->price_amount, $rate->currency) }}

                                    @endforeach

                            </fieldset>
                            @error('shippingRateId')
{{ $message }}
@enderror
                            <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                                Continue to payment
                                Saving…
                            </button>
                        @endif
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your shipping address first.

                @endif

                    <button type="button" wire:click="setActiveStep(4)" @disabled($activeStep < 4) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-payment-panel" aria-expanded="{{ $activeStep === 4 ? 'true' : 'false' }}">
                        4

                            Payment method
                            @if ($checkout->payment_method)
                                {{ ucfirst(str_replace('_', ' ', $checkout->payment_method)) }}
                            @endif

                    </button>

                @if ($activeStep === 4)
                    <form id="checkout-payment-panel" wire:submit="pay" class="p-5 sm:p-6">
                        <fieldset wire:loading.attr="disabled" wire:target="pay">
                            <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a payment method</legend>

                                @foreach (['credit_card' => 'Credit card', 'paypal' => 'PayPal', 'bank_transfer' => 'Bank transfer'] as $value => $label)

                                        <input id="payment-{{ $value }}" type="radio" wire:model.live="paymentMethod" value="{{ $value }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">
                                        {{ $label }}

                                @endforeach

                        </fieldset>
                        @error('paymentMethod')
{{ $message }}
@enderror

                        @if ($paymentMethod === 'credit_card')

                                    Card number *
                                    <input id="card-number" type="text" inputmode="numeric" wire:model.blur="cardNumber" autocomplete="cc-number" required aria-describedby="card-number-error" placeholder="4242 4242 4242 4242" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 tracking-wider focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardNumber')
{{ $message }}
@enderror

                                    Cardholder name *
                                    <input id="cardholder-name" type="text" wire:model.blur="cardholderName" autocomplete="cc-name" required aria-describedby="cardholder-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardholderName')
{{ $message }}
@enderror

                                    Expiry *
                                    <input id="card-expiry" type="text" inputmode="numeric" wire:model.blur="cardExpiry" autocomplete="cc-exp" required aria-describedby="card-expiry-error" placeholder="MM/YY" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardExpiry')
{{ $message }}
@enderror

                                    CVC *
                                    <input id="card-cvc" type="text" inputmode="numeric" wire:model.blur="cardCvc" autocomplete="cc-csc" required aria-describedby="card-cvc-error" placeholder="123" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardCvc')
{{ $message }}
@enderror

                        @elseif ($paymentMethod === 'paypal')

Your PayPal payment will be processed securely onsite. No external redirect is required.

                        @else

After placing your order, you will receive bank transfer instructions. Your order will be held for 7 days while we await your payment.

                        @endif

                        @error('payment')

{{ $message }}

                        @enderror
                        @if ($message)

{{ $message }}

                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-12 w-full items-center justify-center rounded-full bg-blue-600 px-5 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-wait disabled:opacity-60 dark:focus:ring-offset-zinc-950">

                                @if ($paymentMethod === 'paypal')
                                    Pay with PayPal - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @elseif ($paymentMethod === 'bank_transfer')
                                    Place order - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @else
                                    Pay now - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @endif

                            Processing…
                        </button>
                    </form>
                @elseif ($activeStep < 4)

Choose your shipping method first.

                @endif

Order summary

                {{ $checkout->cart->itemCount() }} {{ $checkout->cart->itemCount() === 1 ? 'item' : 'items' }}

                @foreach ($checkout->cart->lines as $line)

id }}" class="flex gap-3 py-4 first:pt-0 last:pb-0">
                        @if ($line->variant->product->media->first()?->url)
                            variant->product->media->first()->url }}" alt="{{ $line->variant->product->title }}" class="h-12 w-12 shrink-0 rounded-lg object-cover" loading="lazy">

formatted_output:
Warning: truncated output (original token count: 13151)
Total output lines: 660

<?php

namespace App\Livewire\Storefront\Checkout;

use App\Enums\CheckoutStatus;
use App\Enums\PaymentMethod;
use App\Exceptions\InvalidDiscountException;
use App\Models\Checkout as CheckoutModel;
use App\Models\CustomerAddress;
use App\Services\CheckoutService;
use App\Services\DiscountService;
use App\Services\PaymentService;
use App\Services\PricingEngine;
use App\Services\ShippingCalculator;
use Carbon\Carbon;
use Livewire\Component;
use Throwable;

class Show extends Component
{
    public CheckoutModel $checkout;

    public string $email = '';

    /** @var array<string, string> */
    public array $shippingAddress = [
        'first_name' => '',
        'last_name' => '',
        'address1' => '',
        'address2' => '',
        'city' => '',
        'state' => '',
        'country_code' => 'DE',
        'postal_code' => '',
        'phone' => '',
    ];

    /** @var array<string, string> */
    public array $billingAddress = [
        'first_name' => '',
        'last_name' => '',
        'address1' => '',
        'address2' => '',
        'city' => '',
        'state' => '',
        'country_code' => 'DE',
        'postal_code' => '',
        'phone' => '',
    ];

    public bool $billingSameAsShipping = true;

    public ?int $savedAddressId = null;

    public ?int $shippingRateId = null;

    public string $paymentMethod = PaymentMethod::CreditCard->value;

    public string $cardNumber = '4242424242424242';

    public string $cardholderName = '';

    public string $cardExpiry = '';

    public string $cardCvc = '';

    public string $discountCode = '';

    public string $message = '';

    public bool $processing = false;

    public int $activeStep = 1;

    public bool $showOrderSummary = false;

    public function mount(int $checkoutId): void
    {
        $this->checkout = CheckoutModel::query()
            ->with(['cart.lines.variant.product.media', 'shippingRate'])
            ->findOrFail($checkoutId);

        $customerId = auth('customer')->id();
        $sessionCartIds = array_filter([
            session('cart_id'),
            session('cart_id_'.app('current_store')->getKey()),
        ]);

        abort_unless(
            ($customerId !== null && (int) $this->checkout->customer_id === (int) $customerId)
                || ($customerId === null && in_array($this->checkout->cart_id, $sessionCartIds, true)),
            404,
        );

        $this->email = (string) $this->checkout->email;
        $this->discountCode = (string) ($this->checkout->discount_code ?? '');
        $this->shippingRateId = $this->checkout->shipping_rate_id;
        $this->paymentMethod = (string) ($this->checkout->payment_method ?? PaymentMethod::CreditCard->value);

        if ($this->checkout->shipping_address_json !== null) {
            $this->shippingAddress = array_merge($this->shippingAddress, $this->checkout->shipping_address_json);
        }

        if ($this->checkout->billing_address_json !== null) {
            $this->billingAddress = array_merge($this->billingAddress, $this->checkout->billing_address_json);
            $this->billingSameAsShipping = $this->billingAddress === $this->shippingAddress;
        }

        $this->activeStep = match ($this->checkout->status) {
            CheckoutStatus::Started => 1,
            CheckoutStatus::Addressed => 3,
            CheckoutStatus::ShippingSelected, CheckoutStatus::PaymentSelected, CheckoutStatus::PaymentPending, CheckoutStatus::Completed => 4,
            default => 1,
        };
    }

    public function saveContact(): void
    {
        $this->validate([
            'email' => ['required', 'email', 'max:255'],
        ], [
            'email.required' => 'Enter an email address to receive your order confirmation.',
        ]);

        $this->checkout->update(['email' => $this->email]);
        $this->checkout->refresh();
        $this->message = 'Contact information saved.';
        $this->activeStep = 2;
    }

    public function saveAddress(CheckoutService $checkouts, PricingEngine $pricing): void
    {
        $this->normalizeAddresses();

        $rules = [
            'email' => ['required', 'email', 'max:255'],
            ...$this->addressRules('shippingAddress'),
        ];

        if (! $this->billingSameAsShipping) {
            $rules = [...$rules, ...$this->addressRules('billingAddress')];
        }

        $this->validate($rules);

        $this->checkout->update(['email' => $this->email]);
        $this->checkout = $checkouts->setAddress(
            $this->checkout->refresh(),
            $this->shippingAddress,
            $this->billingAddress,
            $this->billingSameAsShipping,
        );

        if ($this->requiresShipping()) {
            $this->checkout->update([
                'shipping_rate_id' => null,
                'shipping_method_id' => null,
                'status' => CheckoutStatus::Addressed,
            ]);
            $this->checkout = $this->checkout->refresh();
            $pricing->calculate($this->checkout);
            $this->checkout = $this->checkout->refresh();
            $this->shippingRateId = null;
            $this->activeStep = 3;
        } else {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, 0);
            $this->shippingRateId = null;
            $this->activeStep = 4;
        }

        $this->message = 'Address saved.';
    }

    public function selectSavedAddress(int|string|null $addressId): void
    {
        $customerId = auth('customer')->id();

        if ($customerId === null || $addressId === null || $addressId === '') {
            $this->savedAddressId = null;

            return;
        }

        $address = CustomerAddress::query()
            ->whereKey((int) $addressId)
            ->where('customer_id', $customerId)
            ->firstOrFail();

        $this->savedAddressId = $address->getKey();
        $this->shippingAddress = array_merge($this->shippingAddress, $address->address_json ?? []);

        if ($this->billingSameAsShipping) {
            $this->billingAddress = $this->shippingAddress;
        }
    }

    public function updatedBillingSameAsShipping(bool $same): void
    {
        if ($same) {
            $this->billingAddress = $this->shippingAddress;
        }
    }

    public function chooseShipping(CheckoutService $checkouts): void
    {
        if (! $this->requiresShipping()) {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, 0);
            $this->activeStep = 4;

            return;
        }

        $this->validate(['shippingRateId' => ['required', 'integer']]);

        try {
            $this->checkout = $checkouts->setShippingMethod($this->checkout, $this->shippingRateId);
            $this->message = 'Shipping method saved.';
            $this->activeStep = 4;
        } catch (Throwable $exception) {
            $this->addError('shippingRateId', $exception->getMessage());
        }
    }

    public function applyDiscount(DiscountService $discounts, PricingEngine $pricing): void
    {
        $this->validate(['discountCode' => ['required', 'string', 'max:64']]);

        try {
            $code = trim($this->discountCode);
            $discount = $discounts->validate($code, app('current_store'), $this->checkout->cart);
            $this->checkout->cart->update(['discount_code' => $discount->code]);
            $this->checkout->update(['discount_code' => $discount->code]);
            $this->checkout = $this->checkout->refresh();
            $pricing->calculate($this->checkout);
            $this->checkout = $this->checkout->refresh();
            $this->checkout->load(['cart.lines.variant.product.media', 'shippingRate']);
            $this->discountCode = $discount->code;
            $this->message = 'Discount applied.';
        } catch (InvalidDiscountException $exception) {
            $this->addError('discountCode', $exception->getMessage());
        }
    }

    public function removeDiscount(PricingEngine $pricing): void
    {
        $this->checkout->cart->update(['discount_code' => null]);
        $this->checkout->update(['discount_code' => null]);
        $this->checkout = $this->checkout->refresh();
        $pricing->calculate($this->checkout);
        $this->checkout = $this->checkout->refresh();
        $this->checkout->load(['cart.lines.variant.product.media', 'shippingRate']);
        $this->discountCode = '';
        $this->message = 'Discount removed.';
        $this->resetValidation('discountCode');
    }

    public function pay(CheckoutService $checkouts, PaymentService $payments): void
    {
        if ($this->processing) {
            return;
        }

        $this->cardNumber = preg_replace('/\D+/', '', $this->cardNumber) ?? '';
        $rules = [
            'email' => ['required', 'email', 'max:255'],
            'paymentMethod' => ['required', 'in:credit_card,paypal,bank_transfer'],
        ];

        if ($this->paymentMethod === PaymentMethod::CreditCard->value) {
            $rules = [
                ...$rules,
                'cardNumber' => ['required', 'digits:16'],
                'cardholderName' => ['required', 'string', 'max:255'],
                'cardExpiry' => ['required', 'regex:/^(0[1-9]|1[0-2])\/\d{2}$/'],
                'cardCvc' => ['required', 'digits_between:3,4'],
            ];
        }

        $this->validate($rules);

        if ($this->paymentMethod === PaymentMethod::CreditCard->value && ! $this->cardExpiryIsFuture()) {
            $this->addError('cardExpiry', 'Enter a future expiry date in MM/YY format.');

            return;
        }

        if ($this->checkout->shipping_address_json === null) {
            $this->addError('payment', 'Save your shipping address before placing the order.');
            $this->activeStep = 2;

            return;
        }

        if ($this->requiresShipping() && $this->checkout->shipping_rate_id === null) {
            $this->addError('payment', 'Choose a shipping method before placing the order.');
            $this->activeStep = 3;

            return;
        }

Secure checkout

Complete your order

Your information is used only to process and deliver this order.

        <button type="button" wire:click="toggleOrderSummary" class="flex min-h-14 w-full items-center justify-between rounded-xl border border-zinc-200 bg-zinc-50 px-4 py-3 text-left dark:border-zinc-800 dark:bg-zinc-900" aria-controls="mobile-order-summary" aria-expanded="{{ $showOrderSummary ? 'true' : 'false' }}">

                {{ $showOrderSummary ? 'Hide order summary' : 'Show order summary' }}
                {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}

            {{ $showOrderSummary ? '⌃' : '⌄' }}
        </button>

                    <button type="button" wire:click="setActiveStep(1)" class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 dark:focus:ring-offset-zinc-900" aria-controls="checkout-contact-panel" aria-expanded="{{ $activeStep === 1 ? 'true' : 'false' }}">
                         1 ? 'bg-green-600 text-white' : 'bg-blue-600 text-white' }} text-sm font-bold">{{ $activeStep > 1 ? '✓' : '1' }}

                            Contact information
                            @if ($activeStep > 1)
                                {{ $checkout->email }}
                            @endif

                    </button>
                    @if ($activeStep > 1)
                        <button type="button" wire:click="setActiveStep(1)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 1)
                    <form id="checkout-contact-panel" wire:submit="saveContact" class="space-y-4 p-5 sm:p-6">

                            Email address *
                            <input id="checkout-email" type="email" wire:model.blur="email" autocomplete="email" required aria-describedby="checkout-email-help checkout-email-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 text-zinc-950 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">

We’ll send your order confirmation here.

                            @error('email')

{{ $message }}

                            @enderror

Already have an account? Log in

                        <button type="submit" wire:loading.attr="disabled" class="inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                            Continue to shipping address
                            Saving…
                        </button>
                    </form>
                @endif

                    <button type="button" wire:click="setActiveStep(2)" @disabled($activeStep < 2) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-address-panel" aria-expanded="{{ $activeStep === 2 ? 'true' : 'false' }}">
                        shipping_address_json !== null ? 'bg-green-600 text-white' : 'bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300' }} text-sm font-bold">{{ $checkout->shipping_address_json !== null && $activeStep !== 2 ? '✓' : '2' }}

                            Shipping address
                            @if ($checkout->shipping_address_json !== null && $activeStep !== 2)
                                {{ $shippingAddress['city'] }}, {{ $shippingAddress['country_code'] }}
                            @endif

                    </button>
                    @if ($checkout->shipping_address_json !== null && $activeStep !== 2)
                        <button type="button" wire:click="setActiveStep(2)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 2)
                    <form id="checkout-address-panel" wire:submit="saveAddress" class="space-y-6 p-5 sm:p-6">
                        @if ($savedAddresses->isNotEmpty())

                                Use a saved address
                                <select id="saved-address" wire:model.live="savedAddressId" wire:change="selectSavedAddress($event.target.value)" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 text-zinc-950 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    <option value="">Use a new address</option>
                                    @foreach ($savedAddresses as $address)
                                        <option wire:key="saved-address-{{ $address->id }}" value="{{ $address->id }}">{{ $address->label ?: 'Saved address' }}{{ $address->is_default ? ' (default)' : '' }}</option>
                                    @endforeach
                                </select>

                        @endif

                        <fieldset>
                            <legend class="text-base font-semibold text-zinc-950 dark:text-white">Shipping address</legend>

                                    First name *
                                    <input id="shipping-first-name" type="text" wire:model.blur="shippingAddress.first_name" autocomplete="given-name" required aria-describedby="shipping-first-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('shippingAddress.first_name')
{{ $message }}
@enderror

                                    Last name *
                                    <input id="shipping-last-name" type="text" wire…3151 tokens truncated…c-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.state')
{{ $message }}
@enderror

                                        Postal code *
                                        <input id="billing-postal-code" type="text" wire:model.blur="billingAddress.postal_code" autocomplete="billing postal-code" required aria-describedby="billing-postal-code-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.postal_code')
{{ $message }}
@enderror

                                        Country *
                                        <select id="billing-country" wire:model.blur="billingAddress.country_code" autocomplete="billing country" required aria-describedby="billing-country-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                            <option value="DE">Germany</option>
                                            <option value="AT">Austria</option>
                                            <option value="CH">Switzerland</option>
                                            <option value="GB">United Kingdom</option>
                                            <option value="US">United States</option>
                                        </select>
                                        @error('billingAddress.country_code')
{{ $message }}
@enderror

                            </fieldset>
                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                            Continue to shipping
                            Saving…
                        </button>
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your contact information first.

                @endif

                    <button type="button" wire:click="setActiveStep(3)" @disabled($activeStep < 3) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-shipping-panel" aria-expanded="{{ $activeStep === 3 ? 'true' : 'false' }}">
                        shipping_rate_id !== null || ! $this->requiresShipping() ? 'bg-green-600 text-white' : 'bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300' }} text-sm font-bold">{{ ($checkout->shipping_rate_id !== null || ! $this->requiresShipping()) && $activeStep !== 3 ? '✓' : '3' }}

                            Shipping method
                            @if (! $this->requiresShipping())
                                No shipping required
                            @elseif ($checkout->shippingRate && $activeStep !== 3)
                                {{ $checkout->shippingRate->name }}
                            @endif

                    </button>
                    @if ($activeStep > 3 && $this->requiresShipping())
                        <button type="button" wire:click="setActiveStep(3)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 3)
                    <form id="checkout-shipping-panel" wire:submit="chooseShipping" class="p-5 sm:p-6">
                        @if ($rates->isEmpty())

No shipping methods are available for your address.

Please verify your address or contact us.

                        @else
                            <fieldset>
                                <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a shipping method *</legend>

                                    @foreach ($rates as $rate)
                                        id }}" class="flex cursor-pointer items-center gap-4 rounded-xl border p-4 transition has-[:checked]:border-blue-600 has-[:checked]:bg-blue-50 dark:has-[:checked]:bg-blue-950/20 {{ (int) $shippingRateId === (int) $rate->id ? 'border-blue-600 bg-blue-50 dark:bg-blue-950/20' : 'border-zinc-200 dark:border-zinc-700' }}">
                                            <input id="shipping-rate-{{ $rate->id }}" type="radio" wire:model="shippingRateId" value="{{ $rate->id }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">

                                                {{ $rate->name }}

                                                    @if ($rate->estimated_days_min && $rate->estimated_days_max)
                                                        {{ $rate->estimated_days_min }}–{{ $rate->estimated_days_max }} business days
                                                    @else
                                                        Delivery time shown at dispatch
                                                    @endif

                                            {{ $this->formatMoney($rate->price_amount, $rate->currency) }}

                                    @endforeach

                            </fieldset>
                            @error('shippingRateId')
{{ $message }}
@enderror
                            <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                                Continue to payment
                                Saving…
                            </button>
                        @endif
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your shipping address first.

                @endif

                    <button type="button" wire:click="setActiveStep(4)" @disabled($activeStep < 4) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-payment-panel" aria-expanded="{{ $activeStep === 4 ? 'true' : 'false' }}">
                        4

                            Payment method
                            @if ($checkout->payment_method)
                                {{ ucfirst(str_replace('_', ' ', $checkout->payment_method)) }}
                            @endif

                    </button>

                @if ($activeStep === 4)
                    <form id="checkout-payment-panel" wire:submit="pay" class="p-5 sm:p-6">
                        <fieldset wire:loading.attr="disabled" wire:target="pay">
                            <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a payment method</legend>

                                @foreach (['credit_card' => 'Credit card', 'paypal' => 'PayPal', 'bank_transfer' => 'Bank transfer'] as $value => $label)

                                        <input id="payment-{{ $value }}" type="radio" wire:model.live="paymentMethod" value="{{ $value }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">
                                        {{ $label }}

                                @endforeach

                        </fieldset>
                        @error('paymentMethod')
{{ $message }}
@enderror

                        @if ($paymentMethod === 'credit_card')

                                    Card number *
                                    <input id="card-number" type="text" inputmode="numeric" wire:model.blur="cardNumber" autocomplete="cc-number" required aria-describedby="card-number-error" placeholder="4242 4242 4242 4242" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 tracking-wider focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardNumber')
{{ $message }}
@enderror

                                    Cardholder name *
                                    <input id="cardholder-name" type="text" wire:model.blur="cardholderName" autocomplete="cc-name" required aria-describedby="cardholder-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardholderName')
{{ $message }}
@enderror

                                    Expiry *
                                    <input id="card-expiry" type="text" inputmode="numeric" wire:model.blur="cardExpiry" autocomplete="cc-exp" required aria-describedby="card-expiry-error" placeholder="MM/YY" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardExpiry')
{{ $message }}
@enderror

                                    CVC *
                                    <input id="card-cvc" type="text" inputmode="numeric" wire:model.blur="cardCvc" autocomplete="cc-csc" required aria-describedby="card-cvc-error" placeholder="123" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardCvc')
{{ $message }}
@enderror

                        @elseif ($paymentMethod === 'paypal')

Your PayPal payment will be processed securely onsite. No external redirect is required.

                        @else

After placing your order, you will receive bank transfer instructions. Your order will be held for 7 days while we await your payment.

                        @endif

                        @error('payment')

{{ $message }}

                        @enderror
                        @if ($message)

{{ $message }}

                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-12 w-full items-center justify-center rounded-full bg-blue-600 px-5 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-wait disabled:opacity-60 dark:focus:ring-offset-zinc-950">

                                @if ($paymentMethod === 'paypal')
                                    Pay with PayPal - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @elseif ($paymentMethod === 'bank_transfer')
                                    Place order - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @else
                                    Pay now - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @endif

                            Processing…
                        </button>
                    </form>
                @elseif ($activeStep < 4)

Choose your shipping method first.

                @endif

Order summary

                {{ $checkout->cart->itemCount() }} {{ $checkout->cart->itemCount() === 1 ? 'item' : 'items' }}

                @foreach ($checkout->cart->lines as $line)

id }}" class="flex gap-3 py-4 first:pt-0 last:pb-0">
                        @if ($line->variant->product->media->first()?->url)
                            variant->product->media->first()->url }}" alt="{{ $line->variant->product->title }}" class="h-12 w-12 shrink-0 rounded-lg object-cover" loading="lazy">


text:
Script completed
Wall time 0.1 seconds
Output:

text:
Warning: truncated output (original token count: 18290)
Total output lines: 972

<?php

namespace App\Livewire\Storefront\Cart;

use App\Exceptions\InvalidDiscountException;
use App\Models\Cart;
use App\Services\CartService;
use App\Services\CheckoutService;
use App\Services\DiscountService;
use Livewire\Component;

class Show extends Component
{
    public Cart $cart;

    public string $discountCode = '';

    public string $message = '';

    public int $discountAmount = 0;

    public int $totalAmount = 0;

    public function mount(CartService $carts, DiscountService $discounts): void
    {
        $this->cart = $carts->getOrCreateForSession(app('current_store'), auth('customer')->user());
        $this->discountCode = (string) ($this->cart->discount_code ?? '');
        $this->refreshCart($discounts);
    }

    public function increase(int $lineId, CartService $carts, DiscountService $discounts): void
    {
        $line = $this->cart->lines->firstWhere('id', $lineId);

        if ($line === null) {
            return;
        }

        $carts->updateLineQuantity($this->cart, $lineId, $line->quantity + 1);
        $this->refreshCart($discounts);
    }

    public function decrease(int $lineId, CartService $carts, DiscountService $discounts): void
    {
        $line = $this->cart->lines->firstWhere('id', $lineId);

        if ($line === null) {
            return;
        }

        if ($line->quantity > 1) {
            $carts->updateLineQuantity($this->cart, $lineId, $line->quantity - 1);
        }

        $this->refreshCart($discounts);
    }

    public function remove(int $lineId, CartService $carts, DiscountService $discounts): void
    {
        if (! $this->cart->lines->contains('id', $lineId)) {
            return;
        }

        $carts->removeLine($this->cart, $lineId);
        $this->message = 'Item removed from your cart.';
        $this->refreshCart($discounts);
    }

    public function checkout(CheckoutService $checkouts): void
    {
        if ($this->cart->lines->isEmpty()) {
            $this->addError('cart', 'Your cart is empty.');

            return;
        }

        $checkout = $checkouts->create($this->cart, auth('customer')->user()?->email ?? 'guest@example.com', auth('customer')->user());
        $this->redirect(route('checkout.show', $checkout), navigate: true);
    }

    public function applyDiscount(DiscountService $discounts): void
    {
        $this->validate(['discountCode' => ['required', 'string', 'max:64']]);

        try {
            $discount = $discounts->validate(trim($this->discountCode), app('current_store'), $this->cart);
            $this->cart->update(['discount_code' => $discount->code]);
            $this->discountCode = $discount->code;
            $this->message = 'Discount applied.';
            $this->resetValidation('discountCode');
            $this->refreshCart($discounts);
        } catch (InvalidDiscountException $exception) {
            $this->addError('discountCode', $exception->getMessage());
        }
    }

    public function removeDiscount(DiscountService $discounts): void
    {
        $this->cart->update(['discount_code' => null]);
        $this->discountCode = '';
        $this->message = 'Discount removed.';
        $this->resetValidation('discountCode');
        $this->refreshCart($discounts);
    }

    public function formatMoney(int|float $amount): string
    {
        return number_format((float) $amount / 100, 2, '.', ',').' '.($this->cart->currency ?: 'EUR');
    }

    private function refreshCart(DiscountService $discounts): void
    {
        $this->cart = $this->cart->refresh()->load(['lines.variant.product.media', 'lines.variant.product.collections', 'lines.variant.inventory']);
        $this->discountAmount = $this->calculateDiscountAmount($discounts);
        $subtotal = (int) $this->cart->lines->sum('line_subtotal_amount');
        $this->totalAmount = max(0, $subtotal - $this->discountAmount);
    }

    private function calculateDiscountAmount(DiscountService $discounts): int
    {
        if ($this->cart->discount_code === null || $this->cart->lines->isEmpty()) {
            return 0;
        }

        try {
            $discount = $discounts->validate($this->cart->discount_code, app('current_store'), $this->cart);
        } catch (InvalidDiscountException) {
            return 0;
        }

        $subtotal = (int) $this->cart->lines->sum('line_subtotal_amount');
        $result = $discounts->calculate($discount, $subtotal, $this->cart->lines->map(fn ($line): array => [
            'line_id' => $line->id,
            'amount' => $line->line_subtotal_amount,
            'product_id' => $line->variant->product_id,
            'collection_ids' => $line->variant->product->collections->modelKeys(),
        ])->all());

        return $result->amount;
    }

    public function render(): mixed
    {
        return view('livewire.storefront.cart.show')->layout('layouts.storefront');
    }
}

Shopping bag

Your cart

{{ $cart->itemCount() }} {{ $cart->itemCount() === 1 ? 'item' : 'items' }}

            Continue shopping

    @if ($message)

{{ $message }}

    @endif

    @error('cart')

{{ $message }}

    @enderror

    @if ($cart->lines->isEmpty())

🛍

Your cart is empty

Add something you love to get started.

                Browse collections

    @else

Items in your cart

                    @foreach ($cart->lines as $line)

id }}" class="rounded-2xl border border-zinc-200 p-4 dark:border-zinc-800">

                                @if ($line->variant->product->media->first()?->url)
                                    variant->product->media->first()->url }}" alt="{{ $line->variant->product->title }}" class="h-24 w-24 shrink-0 rounded-xl object-cover" loading="lazy">
                                @else

⌂

                                @endif

                                    variant->product->handle) }}" class="font-semibold text-zinc-950 underline decoration-transparent underline-offset-4 hover:decoration-current focus:outline-none focus:ring-2 focus:ring-blue-600 dark:text-white" wire:navigate>{{ $line->variant->product->title }}

{{ $line->variant->title }}

{{ $this->formatMoney($line->unit_price_amount) }} each

variant->product->title }}">
                                    <button type="button" wire:click="decrease({{ $line->id }})" wire:loading.attr="disabled" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-zinc-300 text-lg hover:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 disabled:opacity-50 dark:border-zinc-700" aria-label="Decrease quantity of {{ $line->variant->product->title }}">−</button>
                                    {{ $line->quantity }}
                                    <button type="button" wire:click="increase({{ $line->id }})" wire:loading.attr="disabled" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-zinc-300 text-lg hover:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 disabled:opacity-50 dark:border-zinc-700" aria-label="Increase quantity of {{ $line->variant->product->title }}">+</button>

{{ $this->formatMoney($line->line_total_amount) }}

                                    <button type="button" wire:click="remove({{ $line->id }})" wire:loading.attr="disabled" class="mt-1 text-sm font-medium text-red-600 underline underline-offset-4 hover:text-red-700 focus:outline-none focus:ring-2 focus:ring-red-600" aria-label="Remove {{ $line->variant->product->title }} from your cart">Remove</button>

                    @endforeach

Products in your shopping cart

                                Product
                                Price
                                Quantity
                                Total
                                Actions

                            @foreach ($cart->lines as $line)

id }}">

                                            @if ($line->variant->product->media->first()?->url)
                                                variant->product->media->first()->url }}" alt="{{ $line->variant->product->title }}" class="h-16 w-16 shrink-0 rounded-xl object-cover" loading="lazy">
                                            @else

⌂

                                            @endif

                                                variant->product->handle) }}" class="font-semibold text-zinc-950 underline decoration-transparent underline-offset-4 hover:decoration-current focus:outline-none focus:ring-2 focus:ring-blue-600 dark:text-white" wire:navigate>{{ $line->variant->product->title }}

{{ $line->variant->title }}

                                    {{ $this->formatMoney($line->unit_price_amount) }}

variant->product->title }}">
                                            <button type="button" wire:click="decrease({{ $line->id }})" wire:loading.attr="disabled" class="inline-flex h-9 w-9 items-center justify-center rounded-full border border-zinc-300 text-lg hover:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 disabled:opacity-50 dark:border-zinc-700" aria-label="Decrease quantity of {{ $line->variant->product->title }}">−</button>
                                            {{ $line->quantity }}
                                            <button type="button" wire:click="increase({{ $line->id }})" wire:loading.attr="disabled" class="inline-flex h-9 w-9 items-center justify-center rounded-full border border-zinc-300 text-lg hover:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 disabled:opacity-50 dark:border-zinc-700" aria-label="Increase quantity of {{ $line->variant->product->title }}">+</button>

                                    {{ $this->formatMoney($line->line_total_amount) }}

                                        <button type="button" wire:click="remove({{ $line->id }})" wire:loading.attr="disabled" class="text-sm font-medium text-red-600 underline underline-offset-4 hover:text-red-700 focus:outline-none focus:ring-2 focus:ring-red-600" aria-label="Remove {{ $line->variant->product->title }} from your cart">Remove</button>

                            @endforeach

Order summary

                <form wire:submit="applyDiscount" class="mt-6">
                    Discount code

                        <input id="cart-discount" type="text" wire:model.blur="discountCode" autocomplete="off" placeholder="Enter code" class="min-h-11 min-w-0 flex-1 rounded-lg border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-950 placeholder:text-zinc-500 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white" aria-describedby="cart-discount-error">
                        <button type="submit" wire:loading.attr="disabled" class="min-h-11 rounded-lg border border-zinc-300 px-4 py-2 text-sm font-semibold hover:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 disabled:opacity-50 dark:border-zinc-700">Apply</button>

                </form>

                @error('discountCode')

{{ $message }}

                @enderror

                @if ($cart->discount_code)

{{ $cart->discount_code }} applied

                        <button type="button" wire:click="removeDiscount" class="shrink-0 font-medium text-green-800 underline underline-offset-4 hover:text-green-950 focus:outline-none focus:ring-2 focus:ring-green-700 dark:text-green-200">Remove</button>

                @endif

Subtotal

{{ $this->formatMoney($cart->lines->sum('line_subtotal_amount')) }}

                    @if ($discountAmount > 0)

Discount

-{{ $this->formatMoney($discountAmount) }}

                    @endif

Shipping

Calculated at checkout

Total

{{ $this->formatMoney($totalAmount) }}

Shipping and taxes are calculated at checkout.

                <button type="button" wire:click="checkout" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-12 w-full items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-wait disabled:opacity-60 dark:focus:ring-offset-zinc-900">
   …8290 tokens truncated…c-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.state')
{{ $message }}
@enderror

                                        Postal code *
                                        <input id="billing-postal-code" type="text" wire:model.blur="billingAddress.postal_code" autocomplete="billing postal-code" required aria-describedby="billing-postal-code-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                        @error('billingAddress.postal_code')
{{ $message }}
@enderror

                                        Country *
                                        <select id="billing-country" wire:model.blur="billingAddress.country_code" autocomplete="billing country" required aria-describedby="billing-country-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                            <option value="DE">Germany</option>
                                            <option value="AT">Austria</option>
                                            <option value="CH">Switzerland</option>
                                            <option value="GB">United Kingdom</option>
                                            <option value="US">United States</option>
                                        </select>
                                        @error('billingAddress.country_code')
{{ $message }}
@enderror

                            </fieldset>
                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                            Continue to shipping
                            Saving…
                        </button>
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your contact information first.

                @endif

                    <button type="button" wire:click="setActiveStep(3)" @disabled($activeStep < 3) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-shipping-panel" aria-expanded="{{ $activeStep === 3 ? 'true' : 'false' }}">
                        shipping_rate_id !== null || ! $this->requiresShipping() ? 'bg-green-600 text-white' : 'bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300' }} text-sm font-bold">{{ ($checkout->shipping_rate_id !== null || ! $this->requiresShipping()) && $activeStep !== 3 ? '✓' : '3' }}

                            Shipping method
                            @if (! $this->requiresShipping())
                                No shipping required
                            @elseif ($checkout->shippingRate && $activeStep !== 3)
                                {{ $checkout->shippingRate->name }}
                            @endif

                    </button>
                    @if ($activeStep > 3 && $this->requiresShipping())
                        <button type="button" wire:click="setActiveStep(3)" class="shrink-0 text-sm font-semibold text-blue-600 underline underline-offset-4 focus:outline-none focus:ring-2 focus:ring-blue-600">Edit</button>
                    @endif

                @if ($activeStep === 3)
                    <form id="checkout-shipping-panel" wire:submit="chooseShipping" class="p-5 sm:p-6">
                        @if ($rates->isEmpty())

No shipping methods are available for your address.

Please verify your address or contact us.

                        @else
                            <fieldset>
                                <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a shipping method *</legend>

                                    @foreach ($rates as $rate)
                                        id }}" class="flex cursor-pointer items-center gap-4 rounded-xl border p-4 transition has-[:checked]:border-blue-600 has-[:checked]:bg-blue-50 dark:has-[:checked]:bg-blue-950/20 {{ (int) $shippingRateId === (int) $rate->id ? 'border-blue-600 bg-blue-50 dark:bg-blue-950/20' : 'border-zinc-200 dark:border-zinc-700' }}">
                                            <input id="shipping-rate-{{ $rate->id }}" type="radio" wire:model="shippingRateId" value="{{ $rate->id }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">

                                                {{ $rate->name }}

                                                    @if ($rate->estimated_days_min && $rate->estimated_days_max)
                                                        {{ $rate->estimated_days_min }}–{{ $rate->estimated_days_max }} business days
                                                    @else
                                                        Delivery time shown at dispatch
                                                    @endif

                                            {{ $this->formatMoney($rate->price_amount, $rate->currency) }}

                                    @endforeach

                            </fieldset>
                            @error('shippingRateId')
{{ $message }}
@enderror
                            <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-11 items-center justify-center rounded-full bg-blue-600 px-5 py-3 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60 dark:focus:ring-offset-zinc-950">
                                Continue to payment
                                Saving…
                            </button>
                        @endif
                    </form>
                @elseif ($checkout->shipping_address_json === null)

Complete your shipping address first.

                @endif

                    <button type="button" wire:click="setActiveStep(4)" @disabled($activeStep < 4) class="flex min-w-0 items-start gap-3 text-left focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 dark:focus:ring-offset-zinc-900" aria-controls="checkout-payment-panel" aria-expanded="{{ $activeStep === 4 ? 'true' : 'false' }}">
                        4

                            Payment method
                            @if ($checkout->payment_method)
                                {{ ucfirst(str_replace('_', ' ', $checkout->payment_method)) }}
                            @endif

                    </button>

                @if ($activeStep === 4)
                    <form id="checkout-payment-panel" wire:submit="pay" class="p-5 sm:p-6">
                        <fieldset wire:loading.attr="disabled" wire:target="pay">
                            <legend class="text-base font-semibold text-zinc-950 dark:text-white">Select a payment method</legend>

                                @foreach (['credit_card' => 'Credit card', 'paypal' => 'PayPal', 'bank_transfer' => 'Bank transfer'] as $value => $label)

                                        <input id="payment-{{ $value }}" type="radio" wire:model.live="paymentMethod" value="{{ $value }}" class="h-4 w-4 border-zinc-300 text-blue-600 focus:ring-2 focus:ring-blue-600 dark:border-zinc-700">
                                        {{ $label }}

                                @endforeach

                        </fieldset>
                        @error('paymentMethod')
{{ $message }}
@enderror

                        @if ($paymentMethod === 'credit_card')

                                    Card number *
                                    <input id="card-number" type="text" inputmode="numeric" wire:model.blur="cardNumber" autocomplete="cc-number" required aria-describedby="card-number-error" placeholder="4242 4242 4242 4242" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 tracking-wider focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardNumber')
{{ $message }}
@enderror

                                    Cardholder name *
                                    <input id="cardholder-name" type="text" wire:model.blur="cardholderName" autocomplete="cc-name" required aria-describedby="cardholder-name-error" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardholderName')
{{ $message }}
@enderror

                                    Expiry *
                                    <input id="card-expiry" type="text" inputmode="numeric" wire:model.blur="cardExpiry" autocomplete="cc-exp" required aria-describedby="card-expiry-error" placeholder="MM/YY" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardExpiry')
{{ $message }}
@enderror

                                    CVC *
                                    <input id="card-cvc" type="text" inputmode="numeric" wire:model.blur="cardCvc" autocomplete="cc-csc" required aria-describedby="card-cvc-error" placeholder="123" class="mt-2 min-h-11 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white">
                                    @error('cardCvc')
{{ $message }}
@enderror

                        @elseif ($paymentMethod === 'paypal')

Your PayPal payment will be processed securely onsite. No external redirect is required.

                        @else

After placing your order, you will receive bank transfer instructions. Your order will be held for 7 days while we await your payment.

                        @endif

                        @error('payment')

{{ $message }}

                        @enderror
                        @if ($message)

{{ $message }}

                        @endif

                        <button type="submit" wire:loading.attr="disabled" class="mt-6 inline-flex min-h-12 w-full items-center justify-center rounded-full bg-blue-600 px-5 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:cursor-wait disabled:opacity-60 dark:focus:ring-offset-zinc-950">

                                @if ($paymentMethod === 'paypal')
                                    Pay with PayPal - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @elseif ($paymentMethod === 'bank_transfer')
                                    Place order - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @else
                                    Pay now - {{ $this->formatMoney($totals['total'] ?? 0, $totals['currency'] ?? null) }}
                                @endif

                            Processing…
                        </button>
                    </form>
                @elseif ($activeStep < 4)

Choose your shipping method first.

                @endif

Order summary

                {{ $checkout->cart->itemCount() }} {{ $checkout->cart->itemCount() === 1 ? 'item' : 'items' }}

                @foreach ($checkout->cart->lines as $line)

id }}" class="flex gap-3 py-4 first:pt-0 last:pb-0">
                        @if ($line->variant->product->media->first()?->url)
                            variant->product->media->first()->url }}" alt="{{ $line->variant->product->title }}" class="h-12 w-12 shrink-0 rounded-lg object-cover" loading="lazy">


exec

status: completed

input:
const r = await tools.exec_command({
  cmd: "for f in database/seeders/PageSeeder.php database/seeders/NavigationSeeder.php database/seeders/AnalyticsSeeder.php database/seeders/SearchSettingsSeeder.php; do echo ==== $f; cat $f; done; sed -n '1,160p' app/Models/NavigationMenu.php; sed -n '1,180p' app/Models/NavigationItem.php; sed -n '1,140p' app/Models/SearchSettings.php; sed -n '1,150p' database/migrations/2026_08_20_000000_create_shop_schema.php | tail -80",
  workdir: "/Users/wesner/Herd/shop",
  yield_time_ms: 1000,
  max_output_tokens: 18000
});
text(r.output);


type: CommandExecution

command: for f in database/seeders/PageSeeder.php database/seeders/NavigationSeeder.php database/seeders/AnalyticsSeeder.php database/seeders/SearchSettingsSeeder.php; do echo ==== $f; cat $f; done; sed -n '1,160p' app/Models/NavigationMenu.php; sed -n '1,180p' app/Models/NavigationItem.php; sed -n '1,140p' app/Models/SearchSettings.php; sed -n '1,150p' database/migrations/2026_08_20_000000_create_shop_schema.php | tail -80

type: unknown

status: failed

stdout: zsh:1: === not found

aggregated_output: zsh:1: === not found

formatted_output: zsh:1: === not found


text:
Script completed
Wall time 0.1 seconds
Output:

text: zsh:1: === not found


status: completed

input:
const r = await tools.exec_command({
  cmd: "sed -n '1,160p' database/seeders/PageSeeder.php; sed -n '1,160p' database/seeders/NavigationSeeder.php; sed -n '1,160p' database/seeders/AnalyticsSeeder.php; sed -n '1,160p' database/seeders/SearchSettingsSeeder.php; sed -n '1,180p' app/Models/NavigationMenu.php; sed -n '1,180p' app/Models/NavigationItem.php; sed -n '1,160p' app/Models/SearchSettings.php",
  workdir: "/Users/wesner/Herd/shop",
  yield_time_ms: 1000,
  max_output_tokens: 18000
});
text(r.output);


command: sed -n '1,160p' database/seeders/PageSeeder.php; sed -n '1,160p' database/seeders/NavigationSeeder.php; sed -n '1,160p' database/seeders/AnalyticsSeeder.php; sed -n '1,160p' database/seeders/SearchSettingsSeeder.php; sed -n '1,180p' app/Models/NavigationMenu.php; sed -n '1,180p' app/Models/NavigationItem.php; sed -n '1,160p' app/Models/SearchSettings.php

PageSeeder.php

type: read

SearchSettings.php

stdout:
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class PageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class NavigationSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class AnalyticsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class SearchSettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class NavigationMenu extends Model
{
    use BelongsToStore;

    protected $fillable = ['store_id', 'name', 'title', 'handle'];

    public function items(): HasMany
    {
        return $this->hasMany(NavigationItem::class)->orderBy('position');
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    protected $fillable = ['navigation_menu_id', 'menu_id', 'label', 'type', 'url', 'resource_id', 'position', 'parent_id'];

    public function menu(): BelongsTo
    {
        return $this->belongsTo(NavigationMenu::class, 'navigation_menu_id');
    }

    public function parent(): BelongsTo
    {
        return $this->belongsTo(self::class, 'parent_id');
    }
}
sed: app/Models/SearchSettings.php: No such file or directory


text:
Script completed
Wall time 0.1 seconds
Output:

text:
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class PageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class NavigationSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class AnalyticsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class SearchSettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
    }
}
<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class NavigationMenu extends Model
{
    use BelongsToStore;

    protected $fillable = ['store_id', 'name', 'title', 'handle'];

    public function items(): HasMany
    {
        return $this->hasMany(NavigationItem::class)->orderBy('position');
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    protected $fillable = ['navigation_menu_id', 'menu_id', 'label', 'type', 'url', 'resource_id', 'position', 'parent_id'];

    public function menu(): BelongsTo
    {
        return $this->belongsTo(NavigationMenu::class, 'navigation_menu_id');
    }

    public function parent(): BelongsTo
    {
        return $this->belongsTo(self::class, 'parent_id');
    }
}
sed: app/Models/SearchSettings.php: No such file or directory


exec

status: completed

input:
const r = await tools.exec_command({
  cmd: "rg -n \"SearchSetting|search_settings\" app database | head -100; sed -n '1,120p' database/seeders/ShopSeeder.php; sed -n '1,180p' database/factories/PageFactory.php; sed -n '1,160p' app/Models/Page.php",
  workdir: "/Users/wesner/Herd/shop",
  yield_time_ms: 1000,
  max_output_tokens: 14000
});
text(r.output);