generated from boboko/starter
288 lines
16 KiB
PHP
288 lines
16 KiB
PHP
{{--
|
|
The checkout page. Two columns: left is contact + billing + shipping +
|
|
shipping method, right is the order summary (the same cart-body partial the
|
|
drawer uses, minus its own "Checkout" CTA — see .bbk-checkout-summary in
|
|
checkout.css). Stops short of payment for this slice — see
|
|
CheckoutController's class docblock.
|
|
|
|
$cart, $lines, $billingAddress, $shippingAddress, $shippingOptions,
|
|
$countries come from CheckoutController::show().
|
|
--}}
|
|
@extends('layouts.app')
|
|
|
|
@section('title', __('checkout.page.title') . ' — ' . config('app.name'))
|
|
|
|
@section('content')
|
|
<div class="bbk-checkout-page">
|
|
<h1 class="bbk-checkout-heading">{{ __('checkout.page.title') }}</h1>
|
|
|
|
<div class="bbk-checkout">
|
|
<div
|
|
class="bbk-checkout-main"
|
|
data-controller="bbk-checkout-form bbk-payment"
|
|
data-action="input->bbk-checkout-form#scheduleSave"
|
|
data-bbk-checkout-form-save-url-value="{{ route('checkout.address.save', app()->getLocale()) }}"
|
|
data-bbk-checkout-form-select-shipping-url-value="{{ route('checkout.shipping-option.select', app()->getLocale()) }}"
|
|
data-bbk-checkout-form-status-saving-value="{{ __('checkout.page.saving') }}"
|
|
data-bbk-checkout-form-status-saved-value="{{ __('checkout.page.saved') }}"
|
|
data-bbk-checkout-form-status-error-value="{{ __('checkout.page.save_error') }}"
|
|
data-bbk-payment-select-url-value="{{ route('checkout.payment-method.select', app()->getLocale()) }}"
|
|
data-bbk-payment-place-order-url-value="{{ route('checkout.place-order', app()->getLocale()) }}"
|
|
data-bbk-payment-order-status-url-value="{{ route('checkout.order-status', app()->getLocale()) }}"
|
|
data-bbk-payment-stripe-key-value="{{ config('services.stripe.public_key') }}"
|
|
data-bbk-payment-amount-value="{{ $cart?->total?->value ?? 0 }}"
|
|
data-bbk-payment-currency-value="{{ strtolower($cart?->total?->currency?->code ?? 'eur') }}"
|
|
data-bbk-payment-terms-required-value="{{ __('checkout.page.terms_required') }}"
|
|
data-bbk-payment-choose-method-value="{{ __('checkout.page.choose_payment_method') }}"
|
|
data-bbk-payment-generic-error-value="{{ __('checkout.page.payment_failed') }}"
|
|
data-bbk-payment-processing-slow-value="{{ __('checkout.page.payment_processing_slow') }}"
|
|
>
|
|
|
|
{{-- Contact --}}
|
|
<section class="bbk-checkout-section">
|
|
<div
|
|
class="bbk-checkout-tabs"
|
|
role="tablist"
|
|
aria-label="{{ __('checkout.page.contact_heading') }}"
|
|
>
|
|
<button
|
|
type="button"
|
|
class="bbk-checkout-tab"
|
|
role="tab"
|
|
aria-selected="true"
|
|
data-bbk-checkout-form-target="guestTab"
|
|
data-action="bbk-checkout-form#showGuest"
|
|
>{{ __('checkout.page.guest_tab') }}</button>
|
|
|
|
<button
|
|
type="button"
|
|
class="bbk-checkout-tab"
|
|
role="tab"
|
|
aria-selected="false"
|
|
data-bbk-checkout-form-target="loginTab"
|
|
data-action="bbk-checkout-form#showLogin"
|
|
>{{ __('checkout.page.login_tab') }}</button>
|
|
|
|
<div class="bbk-checkout-tab-panel" role="tabpanel" data-bbk-checkout-form-target="guestPanel">
|
|
<x-checkout::field
|
|
name="contact_email"
|
|
label="{{ __('checkout.page.email_label') }}"
|
|
type="email"
|
|
:value="$shippingAddress?->contact_email ?? $billingAddress?->contact_email"
|
|
required
|
|
form="bbk-address-form"
|
|
/>
|
|
|
|
{{-- Abandoned-cart-recovery opt-in. Optional, unticked, never
|
|
required — direct marketing under ePrivacy (GR L. 3471/2006
|
|
art. 11), so it needs an explicit opt-in and checkout can't be
|
|
gated on it. Narrow scope by design (boboko-core's
|
|
setRecoveryConsent) — a general newsletter opt-in, if wanted,
|
|
is a separate checkbox. --}}
|
|
<label class="bbk-checkbox bbk-checkbox--stacked">
|
|
<input
|
|
type="checkbox"
|
|
name="recovery_consent"
|
|
value="1"
|
|
form="bbk-address-form"
|
|
{{ old('recovery_consent', data_get($cart, 'meta.recovery_consent')) ? 'checked' : '' }}
|
|
>
|
|
{{ __('checkout.page.recovery_consent') }}
|
|
</label>
|
|
</div>
|
|
|
|
{{-- Not wired yet — Modules\Core\Auth\Services\UserOtpService exists
|
|
(email + one-time code, passwordless) but nothing in the storefront
|
|
calls it yet. UI placeholder only; see project notes. --}}
|
|
<div class="bbk-checkout-tab-panel" role="tabpanel" hidden data-bbk-checkout-form-target="loginPanel">
|
|
<div class="bbk-field">
|
|
<label class="bbk-field-label" for="bbk-login-email">{{ __('checkout.page.login_email_label') }}</label>
|
|
<input type="email" id="bbk-login-email" class="bbk-field-input" disabled>
|
|
</div>
|
|
<button type="button" class="bbk-checkout-continue" disabled>
|
|
{{ __('checkout.page.send_code') }}
|
|
</button>
|
|
<p class="bbk-checkout-note">{{ __('checkout.page.login_coming_soon') }}</p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
{{-- Autosaves — no submit button. Any `change` inside .bbk-checkout-main
|
|
(this form, plus the contact email/consent which sit outside it but
|
|
link via form="bbk-address-form") is debounced and POSTed as the whole
|
|
form; the shipping-method radios are excluded in scheduleSave(). --}}
|
|
<form
|
|
id="bbk-address-form"
|
|
method="POST"
|
|
action="{{ route('checkout.address.save', app()->getLocale()) }}"
|
|
data-bbk-checkout-form-target="form"
|
|
>
|
|
@csrf
|
|
|
|
{{-- Billing --}}
|
|
<section class="bbk-checkout-section">
|
|
<h2 class="bbk-checkout-section-heading">{{ __('checkout.page.billing_heading') }}</h2>
|
|
|
|
<div class="bbk-field-row">
|
|
<x-checkout::field name="billing_first_name" label="{{ __('checkout.page.first_name') }}" :value="$billingAddress?->first_name" required />
|
|
<x-checkout::field name="billing_last_name" label="{{ __('checkout.page.last_name') }}" :value="$billingAddress?->last_name" required />
|
|
</div>
|
|
|
|
<div class="bbk-field-row">
|
|
<x-checkout::field name="billing_company_name" label="{{ __('checkout.page.company_name') }}" :value="$billingAddress?->company_name" />
|
|
<x-checkout::field name="billing_tax_identifier" label="{{ __('checkout.page.tax_identifier') }}" :value="$billingAddress?->tax_identifier" />
|
|
</div>
|
|
|
|
<x-checkout::field name="billing_line_one" label="{{ __('checkout.page.address_line_one') }}" :value="$billingAddress?->line_one" required />
|
|
<x-checkout::field name="billing_line_two" label="{{ __('checkout.page.address_line_two') }}" :value="$billingAddress?->line_two" />
|
|
|
|
<div class="bbk-field-row">
|
|
<x-checkout::field name="billing_city" label="{{ __('checkout.page.city') }}" :value="$billingAddress?->city" required />
|
|
<x-checkout::field name="billing_postcode" label="{{ __('checkout.page.postcode') }}" :value="$billingAddress?->postcode" required />
|
|
</div>
|
|
|
|
<x-checkout::region-country
|
|
prefix="billing"
|
|
:store-country="$storeCountry"
|
|
:regions="$regions"
|
|
:countries="$countries"
|
|
:address="$billingAddress"
|
|
/>
|
|
|
|
<x-checkout::field name="billing_contact_phone" label="{{ __('checkout.page.phone') }}" type="tel" :value="$billingAddress?->contact_phone" />
|
|
</section>
|
|
|
|
{{-- Shipping --}}
|
|
<section class="bbk-checkout-section">
|
|
<h2 class="bbk-checkout-section-heading">{{ __('checkout.page.shipping_heading') }}</h2>
|
|
|
|
<label class="bbk-checkbox">
|
|
<input
|
|
type="checkbox"
|
|
name="same_as_billing"
|
|
value="1"
|
|
data-bbk-checkout-form-target="sameAsBilling"
|
|
data-action="bbk-checkout-form#toggleSameAsBilling"
|
|
@checked($shipToBilling)
|
|
>
|
|
{{ __('checkout.page.same_as_billing') }}
|
|
</label>
|
|
|
|
<div class="bbk-checkout-shipping-fields" data-bbk-checkout-form-target="shippingFields">
|
|
<div class="bbk-field-row">
|
|
<x-checkout::field name="shipping_first_name" label="{{ __('checkout.page.first_name') }}" :value="$shippingAddress?->first_name" required />
|
|
<x-checkout::field name="shipping_last_name" label="{{ __('checkout.page.last_name') }}" :value="$shippingAddress?->last_name" required />
|
|
</div>
|
|
|
|
<x-checkout::field name="shipping_company_name" label="{{ __('checkout.page.company_name') }}" :value="$shippingAddress?->company_name" />
|
|
|
|
<x-checkout::field name="shipping_line_one" label="{{ __('checkout.page.address_line_one') }}" :value="$shippingAddress?->line_one" required />
|
|
<x-checkout::field name="shipping_line_two" label="{{ __('checkout.page.address_line_two') }}" :value="$shippingAddress?->line_two" />
|
|
|
|
<div class="bbk-field-row">
|
|
<x-checkout::field name="shipping_city" label="{{ __('checkout.page.city') }}" :value="$shippingAddress?->city" required />
|
|
<x-checkout::field name="shipping_postcode" label="{{ __('checkout.page.postcode') }}" :value="$shippingAddress?->postcode" required />
|
|
</div>
|
|
|
|
<x-checkout::region-country
|
|
prefix="shipping"
|
|
:store-country="$storeCountry"
|
|
:regions="$regions"
|
|
:countries="$countries"
|
|
:address="$shippingAddress"
|
|
/>
|
|
|
|
<x-checkout::field name="shipping_contact_phone" label="{{ __('checkout.page.phone') }}" type="tel" :value="$shippingAddress?->contact_phone" />
|
|
</div>
|
|
|
|
<x-checkout::textarea
|
|
name="shipping_delivery_instructions"
|
|
label="{{ __('checkout.page.delivery_instructions') }}"
|
|
:value="$shippingAddress?->delivery_instructions"
|
|
/>
|
|
</section>
|
|
</form>
|
|
|
|
<p
|
|
class="bbk-checkout-status"
|
|
data-bbk-checkout-form-target="status"
|
|
role="status"
|
|
aria-live="polite"
|
|
hidden
|
|
></p>
|
|
|
|
{{-- Shipping method — resolves from the saved shipping address;
|
|
re-rendered as a fragment by bbk-checkout-form after each
|
|
autosave / option change. --}}
|
|
<section class="bbk-checkout-section">
|
|
<h2 class="bbk-checkout-section-heading">{{ __('checkout.page.shipping_method_heading') }}</h2>
|
|
|
|
<div id="bbk-shipping-options" data-bbk-checkout-form-target="shippingOptions">
|
|
@include('checkout::partials.shipping-options', [
|
|
'shippingAddress' => $shippingAddress,
|
|
'shippingOptions' => $shippingOptions,
|
|
])
|
|
</div>
|
|
</section>
|
|
|
|
{{-- Payment --}}
|
|
<section class="bbk-checkout-section">
|
|
<h2 class="bbk-checkout-section-heading">{{ __('checkout.page.payment_heading') }}</h2>
|
|
|
|
<div id="bbk-payment-methods">
|
|
@include('checkout::partials.payment-methods', [
|
|
'paymentMethods' => $paymentMethods,
|
|
'cart' => $cart,
|
|
])
|
|
</div>
|
|
|
|
{{-- Stripe Payment Element mounts here when a Stripe method is picked. --}}
|
|
<div class="bbk-payment-element" data-bbk-payment-target="element" hidden></div>
|
|
|
|
<label class="bbk-checkbox bbk-checkbox--stacked">
|
|
<input type="checkbox" data-bbk-payment-target="terms">
|
|
{!! __('checkout.page.terms_accept', [
|
|
'terms' => route('legal.terms', app()->getLocale()),
|
|
'privacy' => route('legal.privacy', app()->getLocale()),
|
|
]) !!}
|
|
</label>
|
|
|
|
<p class="bbk-checkout-withdrawal">
|
|
{!! __('checkout.page.withdrawal_notice', [
|
|
'link' => route('legal.shipping-returns', app()->getLocale()),
|
|
]) !!}
|
|
</p>
|
|
|
|
<p class="bbk-checkout-error" data-bbk-payment-target="error" role="alert" hidden></p>
|
|
|
|
<button
|
|
type="button"
|
|
class="bbk-checkout-continue"
|
|
data-bbk-payment-target="submit"
|
|
data-action="bbk-payment#placeOrder"
|
|
>
|
|
{{ __('checkout.page.place_order') }}
|
|
</button>
|
|
</section>
|
|
|
|
{{-- Fixed overlay while a payment is confirming (3-D Secure / webhook
|
|
poll). Inside .bbk-checkout-main so bbk-payment can target it. --}}
|
|
<div class="bbk-checkout-processing" data-bbk-payment-target="processing" hidden>
|
|
<span class="bbk-spinner" aria-hidden="true"></span>
|
|
<p data-bbk-payment-target="processingText">{{ __('checkout.page.payment_processing') }}</p>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<aside class="bbk-checkout-aside">
|
|
<div class="bbk-checkout-summary" data-controller="bbk-cart">
|
|
<h2 class="bbk-checkout-summary-heading">{{ __('checkout.page.order_summary_heading') }}</h2>
|
|
<div data-bbk-cart-target="body" aria-live="polite">
|
|
@include('checkout::partials.cart-body')
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
</div>
|
|
</div>
|
|
@endsection
|