@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; $viewStampDiscountAmount = $this->stampDiscountAmount ?? 0; $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 // Calculate original item price (before stamp discount) // If stamp discount was applied, the item amount is discounted $originalItemAmount = $item['amount']; if ($viewStampDiscountAmount > 0 && $viewSelectedStampRuleId) { // Check if this item matches the stamp rule's menu item if (class_exists(\Modules\Loyalty\Entities\LoyaltyStampRule::class)) { $stampRule = \Modules\Loyalty\Entities\LoyaltyStampRule::find($viewSelectedStampRuleId); if ($stampRule && $stampRule->menu_item_id == $item['menu_item']['id']) { // This item received stamp discount // Calculate original price by adding back the discount // The discount was applied proportionally to each matching cart item // We need to find all matching items and calculate discount per item $matchingItems = collect($cartItemList['items'])->filter(function($cartItem) use ($stampRule) { return $cartItem['menu_item']['id'] == $stampRule->menu_item_id; }); // Calculate total quantity of matching items $totalMatchingQuantity = $matchingItems->sum('quantity'); if ($totalMatchingQuantity > 0) { // Calculate discount per unit $discountPerUnit = $viewStampDiscountAmount / $totalMatchingQuantity; // Add back the discount for this item's quantity $originalItemAmount = $item['amount'] + ($discountPerUnit * $item['quantity']); } } } } @endphp
{{ $item['quantity'] }}x {{ $item['menu_item']['name'] }} {{ currency_format($originalItemAmount, $restaurant->currency_id) }}
@empty
{{ __('kiosk::modules.payment.empty') }}
@endforelse
{{ __('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($viewLoyaltyDiscountAmount > 0 && $viewLoyaltyPointsRedeemed > 0)
{{ __('loyalty::app.loyaltyDiscount') }} -{{ currency_format($viewLoyaltyDiscountAmount, $restaurant->currency_id) }}
{{ __('loyalty::app.pointsRedeemed') }}: {{ number_format($viewLoyaltyPointsRedeemed) }} @lang('loyalty::app.points')
@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($viewCustomerId && $viewAvailableLoyaltyPoints == 0)

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

@elseif(!$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 = $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 && !$hasRedeemedStamps)
{{ __('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)
{{ $rule->menuItem->item_name ?? __('loyalty::app.unknownItem') }}
{{ __('loyalty::app.availableStamps') }}: {{ $availableStamps }}/{{ $stampsRequired }}
@if($viewSelectedStampRuleId == $rule->id) @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
@endif @endforeach
@if($viewSelectedStampRuleId)
@endif
@elseif($hasRedeemedStamps)
{{ __('loyalty::app.stampRedemptionApplied') }}
@if($viewStampDiscountAmount > 0)
{{ __('loyalty::app.stampDiscount') }}: -{{ currency_format($viewStampDiscountAmount, $restaurant->currency_id) }}
@endif
@endif @elseif($viewCustomerId && empty($viewCustomerStamps))

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

@elseif(!$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($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