@php // Check if Loyalty module is available before accessing loyalty methods // Use method_exists() instead of class_exists() since we're using the trait $isLoyaltyModuleAvailable = function_exists('module_enabled') && module_enabled('Loyalty') && method_exists($this, 'isLoyaltyEnabled'); // Get loyalty properties for view - must be at top before any usage // Only call methods if module is available and methods exist $isLoyaltyEnabledForKiosk = false; $isPointsEnabledForKiosk = false; $isStampsEnabledForKiosk = false; if ($isLoyaltyModuleAvailable) { try { $isLoyaltyEnabledForKiosk = $this->isLoyaltyEnabled(); if (method_exists($this, 'isPointsEnabledForKiosk')) { $isPointsEnabledForKiosk = $this->isPointsEnabledForKiosk(); } if (method_exists($this, 'isStampsEnabledForKiosk')) { $isStampsEnabledForKiosk = $this->isStampsEnabledForKiosk(); } } catch (\Exception $e) { // Silently fail if methods don't exist } } // Get component properties for view $viewCustomerId = $this->customerId ?? null; $viewAvailableLoyaltyPoints = $this->availableLoyaltyPoints ?? 0; $viewCustomerStamps = $this->customerStamps ?? []; $viewSelectedStampRuleId = $this->selectedStampRuleId ?? null; $viewSelectedStampRuleIds = $this->selectedStampRuleIds ?? []; $viewStampDiscountAmount = $this->stampDiscountAmount ?? 0; $viewStampDiscountBreakdown = $this->stampDiscountBreakdown ?? []; $viewServiceTotal = $serviceTotal ?? 0; $viewChargeBreakdown = $chargeBreakdown ?? []; $viewLoyaltyDiscountAmount = $this->loyaltyDiscountAmount ?? 0; $viewLoyaltyPointsRedeemed = $this->loyaltyPointsRedeemed ?? 0; $viewLoyaltyPointsValue = $this->loyaltyPointsValue ?? 0; $viewMaxLoyaltyDiscount = $this->maxLoyaltyDiscount ?? 0; $viewMinRedeemPoints = $this->minRedeemPoints ?? 0; $viewPointsToRedeem = $this->pointsToRedeem ?? 0; // Debug: Check if we should show loyalty section at all $shouldShowLoyaltySection = $isLoyaltyEnabledForKiosk && ($isPointsEnabledForKiosk || $isStampsEnabledForKiosk); @endphp

{{ __('kiosk::modules.payment.heading') }}

{{ __('kiosk::modules.payment.subheading') }}

{{ __('kiosk::modules.payment.order_summary') }}

@forelse ($cartItemList['items'] as $item) @php $displayItemAmount = $item['amount']; $originalItemAmount = $item['amount']; $hasStampDiscount = false; $stampDiscountLabel = null; if ($viewStampDiscountAmount > 0 && !empty($viewSelectedStampRuleIds)) { if (module_enabled('Loyalty')) { foreach ($viewSelectedStampRuleIds as $ruleId) { $stampRule = \Modules\Loyalty\Entities\LoyaltyStampRule::find($ruleId); if (!$stampRule || $stampRule->menu_item_id != $item['menu_item']['id']) { continue; } $ruleDiscount = $viewStampDiscountBreakdown[$ruleId] ?? 0; if ($ruleDiscount <= 0) { continue; } $matchingItems = collect($cartItemList['items'])->filter(function($cartItem) use ($stampRule) { return $cartItem['menu_item']['id'] == $stampRule->menu_item_id; }); $totalMatchingQuantity = $matchingItems->sum('quantity'); if ($totalMatchingQuantity > 0) { $discountPerUnit = $ruleDiscount / $totalMatchingQuantity; $originalItemAmount = $item['amount'] + ($discountPerUnit * $item['quantity']); $hasStampDiscount = true; if ($stampRule->reward_type === 'discount_percent') { $stampDiscountLabel = __('loyalty::app.discount') . ' ' . number_format($stampRule->reward_value, 2) . '%'; } elseif ($stampRule->reward_type === 'discount_amount') { $stampDiscountLabel = __('loyalty::app.discount'); } } } } } @endphp
{{ $item['quantity'] }}x {{ $item['menu_item']['name'] }} @if($hasStampDiscount) {{ $stampDiscountLabel ?? __('loyalty::app.stampDiscount') }} @endif @if($hasStampDiscount && $originalItemAmount > $displayItemAmount) {{ currency_format($originalItemAmount, $restaurant->currency_id) }} @endif {{ currency_format($displayItemAmount, $restaurant->currency_id) }}
@empty
{{ __('kiosk::modules.payment.empty') }}
@endforelse @if(!empty($viewSelectedStampRuleIds) && module_enabled('Loyalty')) @foreach($viewSelectedStampRuleIds as $ruleId) @php $freeRewardQty = 0; $freeRewardName = null; $selectedRule = \Modules\Loyalty\Entities\LoyaltyStampRule::find($ruleId); if ($selectedRule && $selectedRule->reward_type === 'free_item') { $stampData = collect($viewCustomerStamps)->first(function ($data) use ($ruleId) { return isset($data['rule']) && ($data['rule']->id ?? null) == $ruleId; }); $availableStamps = (int)($stampData['available_stamps'] ?? 0); $stampsRequired = (int)($stampData['stamps_required'] ?? 0); $maxItemsByStamps = ($stampsRequired > 0) ? intdiv($availableStamps, $stampsRequired) : 0; $eligibleQty = collect($cartItemList['items'])->where('menu_item.id', $selectedRule->menu_item_id)->sum('quantity'); $freeRewardQty = max(0, min($eligibleQty, $maxItemsByStamps)); $freeRewardName = $selectedRule->rewardMenuItem->item_name ?? null; } @endphp @if($freeRewardQty > 0 && $freeRewardName)
{{ $freeRewardQty }}x {{ $freeRewardName }} ({{ __('loyalty::app.freeItem') }}) {{ currency_format(0, $restaurant->currency_id) }}
@endif @endforeach @endif
@if($viewLoyaltyDiscountAmount > 0 && $viewLoyaltyPointsRedeemed > 0)
{{ __('loyalty::app.loyaltyDiscount') }} -{{ currency_format($viewLoyaltyDiscountAmount, $restaurant->currency_id) }}
{{ __('loyalty::app.pointsRedeemed') }}: {{ number_format($viewLoyaltyPointsRedeemed) }} @lang('loyalty::app.points')
@endif
{{ __('kiosk::modules.payment.subtotal') }} @if($viewStampDiscountAmount > 0) @lang('loyalty::app.stampDiscount') (-{{ currency_format($viewStampDiscountAmount, $restaurant->currency_id) }}) @endif
{{ currency_format($discountedSubtotal ?? $subtotal, $restaurant->currency_id) }}
@if(!empty($viewChargeBreakdown)) @foreach($viewChargeBreakdown as $charge)
{{ $charge['name'] ?? __('charges.charge') }} {{ currency_format($charge['amount'] ?? 0, $restaurant->currency_id) }}
@endforeach @endif @if($totalTaxAmount > 0) @if($taxMode === 'order' && !empty($taxBreakdown)) @foreach($taxBreakdown as $taxName => $taxInfo)
{{ $taxName }} ({{ number_format($taxInfo['percent'], 2) }}%) {{ currency_format($taxInfo['amount'], $restaurant->currency_id) }}
@endforeach @else @if(!empty($taxBreakdown)) @foreach($taxBreakdown as $taxName => $taxInfo)
{{ $taxName }} ({{ number_format($taxInfo['percent'], 2) }}%) {{ currency_format($taxInfo['amount'], $restaurant->currency_id) }}
@endforeach @else
{{ __('kiosk::modules.payment.tax') }} {{ currency_format($totalTaxAmount, $restaurant->currency_id) }}
@endif @endif @endif
{{ __('kiosk::modules.payment.total') }} {{ currency_format($total, $restaurant->currency_id) }}

{{ __('kiosk::modules.payment.heading') }}

@if($isPointsEnabledForKiosk) @if($viewCustomerId && $viewAvailableLoyaltyPoints > 0)
{{ __('loyalty::app.loyaltyProgram') }}
{{ __('loyalty::app.redeemLoyaltyPoints') }}
@if($viewLoyaltyDiscountAmount > 0) @endif
{{ __('loyalty::app.availablePoints') }}: {{ number_format($viewAvailableLoyaltyPoints) }} @lang('loyalty::app.points')
{{ __('loyalty::app.pointsValue') }}: {{ currency_format($viewLoyaltyPointsValue * $viewAvailableLoyaltyPoints, $restaurant->currency_id) }}
@if($viewMaxLoyaltyDiscount > 0)
{{ __('loyalty::app.maxDiscountToday') }}: {{ currency_format($viewMaxLoyaltyDiscount, $restaurant->currency_id) }}
@endif @if($viewMinRedeemPoints > 0)
{{ __('loyalty::app.minRedeemPoints') }}: {{ number_format($viewMinRedeemPoints) }} @lang('loyalty::app.points')
@endif @if($viewPointsToRedeem > 0 && $viewLoyaltyPointsRedeemed == 0)
{{ __('loyalty::app.pointsToRedeem') }}: {{ number_format($viewPointsToRedeem) }} @lang('loyalty::app.points')
@php // Calculate preview discount amount for display only (not applied) $previewDiscount = 0; if ($viewPointsToRedeem > 0 && $viewLoyaltyPointsValue > 0) { $previewDiscountAmount = $viewPointsToRedeem * $viewLoyaltyPointsValue; if ($viewMaxLoyaltyDiscount > 0) { $previewDiscount = min($previewDiscountAmount, $viewMaxLoyaltyDiscount); } else { $previewDiscount = $previewDiscountAmount; } } @endphp @if($previewDiscount > 0)
{{ __('loyalty::app.discountAmount') }}: {{ currency_format($previewDiscount, $restaurant->currency_id) }}
@endif @endif @if($viewLoyaltyDiscountAmount > 0 && $viewLoyaltyPointsRedeemed > 0)
{{ __('loyalty::app.discountApplied') }}: {{ currency_format($viewLoyaltyDiscountAmount, $restaurant->currency_id) }}
{{ __('loyalty::app.pointsRedeemed') }}: {{ number_format($viewLoyaltyPointsRedeemed) }} @lang('loyalty::app.points')
@endif
@if($viewLoyaltyDiscountAmount > 0 && $viewLoyaltyPointsRedeemed > 0) @elseif($viewAvailableLoyaltyPoints > 0 && $viewLoyaltyPointsRedeemed == 0) @endif
@elseif($isLoyaltyEnabledForKiosk && $viewCustomerId && $viewAvailableLoyaltyPoints == 0)

{{ __('loyalty::app.noPointsAvailable') }}

@elseif($isLoyaltyEnabledForKiosk && !$viewCustomerId)

{{ __('Please provide customer information to redeem loyalty points.') }}

@endif @endif @if($isStampsEnabledForKiosk) @php // Calculate stamp redemption status (outside conditionals so it's available everywhere) $hasRedeemedStamps = (!empty($viewSelectedStampRuleIds) || $viewSelectedStampRuleId !== null) || $viewStampDiscountAmount > 0; $redeemableStamps = collect($viewCustomerStamps)->filter(function ($stampData) { return ($stampData['can_redeem'] ?? false) === true; }); $hasRedeemableStamps = $redeemableStamps->isNotEmpty(); @endphp @if($viewCustomerId && !empty($viewCustomerStamps)) @if($hasRedeemableStamps)
{{ __('loyalty::app.redeemStamps') }}
{{ __('loyalty::app.redeemStampsDescription') }}
@foreach($redeemableStamps as $stampData) @php $rule = $stampData['rule']; $availableStamps = $stampData['available_stamps'] ?? 0; $stampsRequired = $stampData['stamps_required'] ?? 0; $canRedeem = $stampData['can_redeem'] ?? false; @endphp @if($canRedeem) @php $isSelected = in_array($rule->id, $viewSelectedStampRuleIds, true) || $viewSelectedStampRuleId == $rule->id; @endphp
{{ $rule->menuItem->item_name ?? __('loyalty::app.unknownItem') }}
{{ __('loyalty::app.availableStamps') }}: {{ $availableStamps }}/{{ $stampsRequired }}
@if($isSelected) @endif
@if($rule->reward_type === 'free_item')
{{ __('loyalty::app.reward') }}: {{ __('app.freeItem') }} - {{ $rule->rewardMenuItem->item_name ?? __('loyalty::app.unknownItem') }}
@elseif($rule->reward_type === 'discount_percent')
{{ __('loyalty::app.reward') }}: {{ number_format($rule->reward_value, 2) }}% {{ __('loyalty::app.discount') }}
@elseif($rule->reward_type === 'discount_amount')
{{ __('loyalty::app.reward') }}: {{ currency_format($rule->reward_value, $restaurant->currency_id) }} {{ __('loyalty::app.discount') }}
@endif @if(!$isSelected) @else @endif
@endif @endforeach
@endif @elseif($isLoyaltyEnabledForKiosk && $viewCustomerId && empty($viewCustomerStamps))

{{ __('loyalty::app.noStampsAvailable') }}

@elseif($isLoyaltyEnabledForKiosk && !$viewCustomerId)

{{ __('Please provide customer information to redeem stamps.') }}

@endif @endif @if($isLoyaltyEnabledForKiosk && !$isPointsEnabledForKiosk && !$isStampsEnabledForKiosk)

{{ __('Loyalty program is enabled but points and stamps are not enabled for kiosk platform.') }}

@endif
@if(!empty($offlinePaymentMethods) && count($offlinePaymentMethods) > 0) @endif @if($paymentGateway && ($paymentGateway->stripe_status || $paymentGateway->razorpay_status || $paymentGateway->flutterwave_status || $paymentGateway->paypal_status || $paymentGateway->payfast_status || $paymentGateway->paystack_status || $paymentGateway->xendit_status || $paymentGateway->epay_status || $paymentGateway->mollie_status || $paymentGateway->tap_status)) @endif @if($paymentGateway && $paymentGateway->is_qr_payment_enabled) @if($showQrCode && $paymentGateway && $paymentGateway->qr_code_image_url)
UPI QR Code

{{ __('kiosk::modules.payment.upi_qr_code_desc') }}

@endif @endif
@if($isRestaurantOpenForOrders) @else
{{ $restaurantClosedMessage }}
@endif
@lang('modules.order.chooseGateway')
{{ __('kiosk::modules.payment.order_total') }}
{{ currency_format($total, $restaurant->currency_id) }}
@if ($paymentGateway->stripe_status) @endif @if ($paymentGateway->razorpay_status) @endif @if ($paymentGateway->flutterwave_status) @endif @if ($paymentGateway->paypal_status) PayPal @endif @if($paymentGateway->payfast_status) @lang('modules.billing.payfast') @endif @if($paymentGateway->paystack_status) @lang('modules.billing.paystack') @endif @if($paymentGateway->xendit_status) @lang('modules.billing.xendit') @endif @if($paymentGateway->epay_status) @lang('modules.billing.epay') @endif @if ($paymentGateway->mollie_status) @lang('modules.billing.mollie') @endif @if($paymentGateway->tap_status) @lang('modules.billing.tap') @endif
@if($selectedOnlineGateway) @lang('modules.order.payNow') @endif
{{-- Online payment gateway scripts support for kiosk (similar to shop cart) --}} @if($paymentGateway) {{-- Razorpay checkout script --}} @if($paymentGateway->razorpay_status) @endif {{-- Epay checkout script --}} @if($paymentGateway->epay_status) @php $isSandbox = $paymentGateway->epay_mode === 'sandbox'; $epayJsUrl = $isSandbox ? 'https://test-epay.epayment.kz/payform/payment-api.js' : 'https://epay.homebank.kz/payform/payment-api.js'; @endphp @endif {{-- Stripe checkout support for kiosk (similar to shop cart) --}} @if($paymentGateway->stripe_status) @script @endscript @endif @endif {{ __('modules.billing.offlinePaymentMethod') }} @if(!empty($offlinePaymentMethods) && count($offlinePaymentMethods) > 0)
@foreach($offlinePaymentMethods as $offlineMethod) @php // Livewire can hydrate ids as string, so avoid strict comparison issues $isSelected = (string)($selectedOfflineMethodId ?? '') === (string)($offlineMethod->id ?? ''); @endphp @endforeach
@else
{{ __('messages.noOfflinePaymentMethodFound') }}
@endif
@script @endscript