diff --git a/resources/css/checkout.css b/resources/css/checkout.css index fb05402..7aed5b6 100644 --- a/resources/css/checkout.css +++ b/resources/css/checkout.css @@ -975,12 +975,41 @@ textarea.bbk-field-input { resize: vertical; } gap: 1.5rem; } -.bbk-confirmation-address-heading { +.bbk-confirmation-address-heading, +.bbk-confirmation-bank-transfer-heading { margin: 0 0 0.5rem; font-size: 0.9375rem; font-weight: 700; } +.bbk-confirmation-bank-transfer { + padding-top: 1.5rem; + border-top: 1px solid var(--bbk-color-border); +} + +/* Store-authored rich text (ManageStoreDetails' RichEditor) — may be + paragraphs, bold text or a bank/IBAN/BIC table. */ +.bbk-confirmation-bank-transfer-body { + font-size: 0.875rem; + overflow-wrap: anywhere; +} + +.bbk-confirmation-bank-transfer-body > :first-child { margin-top: 0; } +.bbk-confirmation-bank-transfer-body > :last-child { margin-bottom: 0; } + +.bbk-confirmation-bank-transfer-body table { + width: 100%; + border-collapse: collapse; +} + +.bbk-confirmation-bank-transfer-body th, +.bbk-confirmation-bank-transfer-body td { + padding: 0.375rem 0.5rem; + border: 1px solid var(--bbk-color-border); + text-align: left; + vertical-align: top; +} + .bbk-address-lines { font-style: normal; display: flex; diff --git a/resources/views/checkout/confirmation.blade.php b/resources/views/checkout/confirmation.blade.php index 466b117..d7b127a 100644 --- a/resources/views/checkout/confirmation.blade.php +++ b/resources/views/checkout/confirmation.blade.php @@ -2,6 +2,9 @@ Order confirmation. Reached only via a session flash of the placed order id (CheckoutController::confirmation) — not deep-linkable. $order is a Lunar\Models\Order with lines + shipping/billing addresses eager-loaded. + $bankTransferInstructions is already-sanitized HTML from + StoreDetailsService::bankTransferInstructionsFor(), or null unless this + is a bank transfer order with instructions filled in for this locale. --}} @extends('layouts.app') @@ -128,5 +131,12 @@ @endif + + @if ($bankTransferInstructions) +
+

{{ __('checkout.page.confirmation_bank_transfer_heading') }}

+
{!! $bankTransferInstructions !!}
+
+ @endif @endsection diff --git a/src/Checkout/Database/Seeders/CheckoutTranslationsSeeder.php b/src/Checkout/Database/Seeders/CheckoutTranslationsSeeder.php index 1a10180..61057eb 100644 --- a/src/Checkout/Database/Seeders/CheckoutTranslationsSeeder.php +++ b/src/Checkout/Database/Seeders/CheckoutTranslationsSeeder.php @@ -190,6 +190,10 @@ class CheckoutTranslationsSeeder extends Seeder 'Θέλεις να παρακολουθείς την παραγγελία σου; Δημιούργησε λογαριασμό ή', ], 'page.confirmation_billing' => ['Billing', 'Χρέωση'], + 'page.confirmation_bank_transfer_heading' => [ + 'Bank transfer details', + 'Στοιχεία τραπεζικής μεταφοράς', + ], 'page.confirmation_continue' => ['Continue shopping', 'Συνέχεια αγορών'], 'page.box_now_locker_label' => [ 'Choose a Box Now locker', diff --git a/src/Checkout/Http/Controllers/CheckoutController.php b/src/Checkout/Http/Controllers/CheckoutController.php index f7da5ec..c831c70 100644 --- a/src/Checkout/Http/Controllers/CheckoutController.php +++ b/src/Checkout/Http/Controllers/CheckoutController.php @@ -28,6 +28,7 @@ use Modules\Core\Customer\Services\CustomerAccountService; use Modules\Core\Payment\Enums\PaymentResultStatus; use Modules\Core\Payment\Models\PaymentMethod; use Modules\Core\Shipping\Carriers\BoxNow\BoxNowClient; +use Modules\Core\Store\Services\StoreDetailsService; /** * The checkout page — one page, sections (contact / billing / shipping / @@ -554,6 +555,8 @@ class CheckoutController extends Controller return view('checkout::confirmation', [ 'order' => $order, 'paymentMethodName' => $paymentMethodName, + 'bankTransferInstructions' => app(StoreDetailsService::class) + ->bankTransferInstructionsFor($order, $locale), ]); } diff --git a/src/Store/Services/StoreDetailsService.php b/src/Store/Services/StoreDetailsService.php index 90c9931..b91e8e5 100644 --- a/src/Store/Services/StoreDetailsService.php +++ b/src/Store/Services/StoreDetailsService.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Event; use Lunar\Models\Language; use Lunar\Models\Order; use Modules\Core\Order\Services\OrderStatusFlow; +use Modules\Core\Order\Support\OrderReferenceDisplay; use Modules\Core\Store\Events\StoreDetailsUpdated; use Modules\Core\Store\Models\StoreDetails; @@ -39,8 +40,8 @@ class StoreDetailsService } /** - * Null for any non-bank-transfer order — the confirmation email only - * shows this block when there's actually a wire to send (see + * Null for any non-bank-transfer order — the confirmation email and page + * only show this block when there's actually a wire to send (see * BankTransferPaymentDriver's own docblock for why a bank transfer * order stays at 'awaiting_payment' until staff confirm the wire * arrived). Null also when the store hasn't filled the field in for @@ -66,7 +67,30 @@ class StoreDetailsService return null; } - return RichContentRenderer::make($content)->toHtml(); + return $this->fillOrderReference( + RichContentRenderer::make($content)->toHtml(), + $order, + ); + } + + /** + * Replaces a `{order_reference}` (or `{{ order_reference }}`) the shop + * owner typed into the instructions with the order's display reference + * (OrderReferenceDisplay — same form as the email subject). + * + * A plain text replace rather than RichContentRenderer::mergeTags(): + * that only fills genuine Tiptap mergeTag nodes, which this editor never + * creates — Lunar's TranslatedText can't pass mergeTags() through to its + * per-locale RichEditors, so the placeholder is always stored as + * ordinary typed text. + */ + private function fillOrderReference(string $html, Order $order): string + { + return preg_replace( + '/\{\{?\s*order_reference\s*\}\}?/', + e(OrderReferenceDisplay::resolve($order)), + $html, + ); } public function update(array $attributes): StoreDetails