@php /* |-------------------------------------------------------------------------- | Order Status |-------------------------------------------------------------------------- */ $status = $order->status instanceof \BackedEnum ? $order->status->value : (string) $order->status; /* |-------------------------------------------------------------------------- | Order Metadata |-------------------------------------------------------------------------- */ $orderMetadata = is_array($order->metadata) ? $order->metadata : []; /* |-------------------------------------------------------------------------- | Free Shipping |-------------------------------------------------------------------------- */ $freeShipping = filter_var( data_get( $orderMetadata, 'landing_page_free_shipping', data_get( $orderMetadata, 'free_shipping', false ) ), FILTER_VALIDATE_BOOLEAN ); /* |-------------------------------------------------------------------------- | Order Items |-------------------------------------------------------------------------- */ $orderItems = collect( $order->items ?? [] ); /* |-------------------------------------------------------------------------- | Calculate Reliable Totals |-------------------------------------------------------------------------- | | DB total_amount কোনো কারণে 0 হলে items থেকে fallback calculate করবে। | */ $itemsSubtotal = (float) $orderItems->sum( fn ($item) => (float) ($item->line_total ?? 0) ); $storedSubtotal = (float) ($order->subtotal ?? 0); $subtotal = $storedSubtotal > 0 ? $storedSubtotal : $itemsSubtotal; $discountAmount = max( 0, (float) ($order->discount_amount ?? 0) ); $deliveryCharge = $freeShipping ? 0 : max( 0, (float) ($order->delivery_charge ?? 0) ); $extraCharge = max( 0, (float) ($order->extra_charge ?? 0) ); $storedGrandTotal = (float) ($order->total_amount ?? 0); $calculatedGrandTotal = max( 0, $subtotal - $discountAmount + $deliveryCharge + $extraCharge ); $grandTotal = $storedGrandTotal > 0 ? $storedGrandTotal : $calculatedGrandTotal; /* |-------------------------------------------------------------------------- | Landing Page / Product |-------------------------------------------------------------------------- */ $product = $landingPage->product ?? null; $productName = $product?->name ?: $orderItems->first()?->product_name ?: 'Product'; $productSlug = $product?->slug ?: \Illuminate\Support\Str::slug( $productName ); $landingPageUrl = $landingPage->public_url ?? route( 'landing-pages.show', [ 'slug' => $landingPage->slug, ] ); /* |-------------------------------------------------------------------------- | Company + Marketing Settings |-------------------------------------------------------------------------- | | এখানে শুধু browser-side IDs load হবে। | Facebook/TikTok access token NEVER frontend-এ পাঠানো হচ্ছে না। | */ $company = null; $facebookPixel = null; $tiktokPixel = null; $googleTag = null; $facebookVerification = null; $liveChatCode = null; $thirdPartyCode = null; try { if ( \Illuminate\Support\Facades\Schema::hasTable( 'company_settings' ) ) { $company = \Illuminate\Support\Facades\DB::table( 'company_settings' ) ->latest('id') ->first(); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'facebook_pixels' ) ) { $facebookPixel = \Illuminate\Support\Facades\DB::table( 'facebook_pixels' ) ->where( 'is_browser_active', true ) ->latest('id') ->first(); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'tiktok_pixels' ) ) { $tiktokPixel = \Illuminate\Support\Facades\DB::table( 'tiktok_pixels' ) ->where( 'is_browser_active', true ) ->latest('id') ->first(); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'google_tags' ) ) { $googleTag = \Illuminate\Support\Facades\DB::table( 'google_tags' ) ->latest('id') ->first(); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'facebook_domain_verifications' ) ) { $facebookVerification = \Illuminate\Support\Facades\DB::table( 'facebook_domain_verifications' ) ->latest('id') ->first(); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'live_chat_integrations' ) ) { $liveChatCode = \Illuminate\Support\Facades\DB::table( 'live_chat_integrations' ) ->latest('id') ->value( 'script_code' ); } if ( \Illuminate\Support\Facades\Schema::hasTable( 'third_party_integrations' ) ) { $thirdPartyCode = \Illuminate\Support\Facades\DB::table( 'third_party_integrations' ) ->latest('id') ->value( 'script_code' ); } } catch (\Throwable $exception) { /* |-------------------------------------------------------------------------- | Marketing configuration error must NEVER break checkout success page. |-------------------------------------------------------------------------- */ $company = $company ?? null; } /* |-------------------------------------------------------------------------- | Marketing IDs |-------------------------------------------------------------------------- */ $facebookPixelId = trim( (string) ( $facebookPixel->dataset_id ?? '' ) ); $tiktokPixelId = trim( (string) ( $tiktokPixel->pixel_id ?? '' ) ); $googleTagId = trim( (string) ( $googleTag->tag_id ?? $googleTag->measurement_id ?? '' ) ); /* |-------------------------------------------------------------------------- | Facebook Domain Verification |-------------------------------------------------------------------------- | | meta_code field-এ full tag অথবা শুধু verification value — | দুইটাই support করবে। | */ $facebookVerificationContent = ''; $rawVerification = trim( (string) ( $facebookVerification->meta_code ?? '' ) ); if ($rawVerification !== '') { if ( preg_match( '/content=["\']([^"\']+)["\']/i', $rawVerification, $verificationMatch ) ) { $facebookVerificationContent = trim( (string) ( $verificationMatch[1] ?? '' ) ); } else { $facebookVerificationContent = strip_tags( $rawVerification ); } } /* |-------------------------------------------------------------------------- | Marketing Items |-------------------------------------------------------------------------- */ $marketingItems = $orderItems ->map( function ($item) { return [ 'item_id' => (string) ( $item->product_id ?? $item->sku ?? $item->product_name ), 'item_name' => (string) ( $item->product_name ?? 'Product' ), 'item_variant' => $item->variant_name ?: null, 'price' => (float) ( $item->unit_price ?? 0 ), 'quantity' => (int) ( $item->quantity ?? 1 ), ]; } ) ->values() ->all(); /* |-------------------------------------------------------------------------- | Product IDs for Meta / TikTok |-------------------------------------------------------------------------- */ $contentIds = $orderItems ->map( fn ($item) => (string) ( $item->product_id ?? $item->sku ?? '' ) ) ->filter() ->values() ->all(); /* |-------------------------------------------------------------------------- | Purchase Event ID |-------------------------------------------------------------------------- | | SAME event ID server-side CAPI event-এ ব্যবহার করবেন। | */ $purchaseEventId = 'purchase_' . (string) $order->order_number; /* |-------------------------------------------------------------------------- | Page Bootstrap |-------------------------------------------------------------------------- */ $successPageData = [ 'orderNumber' => (string) $order->order_number, 'eventId' => $purchaseEventId, 'currency' => (string) ( $order->currency ?: 'BDT' ), 'value' => $grandTotal, 'subtotal' => $subtotal, 'deliveryCharge' => $deliveryCharge, 'discountAmount' => $discountAmount, 'extraCharge' => $extraCharge, 'productName' => $productName, 'productSlug' => $productSlug, 'contentIds' => $contentIds, 'items' => $marketingItems, ]; @endphp {{-- ================================================================ PRIVATE SUCCESS PAGE SEO ================================================================= --}} অর্ডার সফল — {{ $order->order_number }} @if ($facebookVerificationContent !== '') @endif {{-- ================================================================ Fonts & Icons ================================================================= --}} {{-- ================================================================ Facebook Pixel ================================================================= --}} @if ($facebookPixelId !== '') @endif {{-- ================================================================ TikTok Pixel ================================================================= --}} @if ($tiktokPixelId !== '') @endif {{-- ================================================================ Google Tag / GA4 ================================================================= --}} @if ($googleTagId !== '') @endif
Order Confirmed

আপনার অর্ডার সফল হয়েছে!

ধন্যবাদ। আপনার অর্ডারটি সফলভাবে গ্রহণ করা হয়েছে। আমরা খুব শীঘ্রই আপনার সঙ্গে যোগাযোগ করব।

Order Number {{ $order->order_number }}
Total Amount ৳{{ number_format($grandTotal, 0) }}
Order Status {{ \Illuminate\Support\Str::headline($status) }}
Payment Cash On Delivery
আরও পণ্য দেখুন হোম পেজ
{{-- ================================================================ JS Purchase Payload ================================================================ --}} {{-- ================================================================ Purchase Marketing Events (Facebook, TikTok, GA4) ================================================================ --}} {{-- ================================================================ Trusted Admin Live Chat Integration ================================================================ --}} @if (filled($liveChatCode)) {!! $liveChatCode !!} @endif {{-- ================================================================ Trusted Admin Third Party Integration ================================================================ --}} @if (filled($thirdPartyCode)) {!! $thirdPartyCode !!} @endif