@if($isLoyaltyEnabled ?? false) @php // Always prioritize order data from database (source of truth) $displayLoyaltyPointsRedeemed = (float)($order->loyalty_points_redeemed ?? 0); $displayLoyaltyDiscountAmount = (float)($order->loyalty_discount_amount ?? 0); // Fallback to component variables only if order values are 0 if ($displayLoyaltyPointsRedeemed == 0) { $displayLoyaltyPointsRedeemed = (float)($loyaltyPointsRedeemed ?? 0); } if ($displayLoyaltyDiscountAmount == 0) { $displayLoyaltyDiscountAmount = (float)($loyaltyDiscountAmount ?? 0); } @endphp @if($displayLoyaltyPointsRedeemed > 0 && $displayLoyaltyDiscountAmount > 0)

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

{{ number_format($displayLoyaltyPointsRedeemed, 0) }} @lang('loyalty::app.points') = {{ currency_format($displayLoyaltyDiscountAmount, $restaurant->currency_id) }}

@php $isPaid = $order->isFullyPaid(); @endphp @if(!$isPaid) {{ __('loyalty::app.remove') }} ... @endif
@endif @endif @php // Display stamp redemption with remove button (similar to loyalty points) $displayStampDiscountAmount = (float)($order->stamp_discount_amount ?? 0); if ($displayStampDiscountAmount == 0) { $displayStampDiscountAmount = (float)($stampDiscountAmount ?? 0); } $hasFreeStampItems = $order->items()->where('is_free_item_from_stamp', true)->exists(); @endphp @if(($isStampsEnabledForCustomerSite ?? false) && ($displayStampDiscountAmount > 0 || $hasFreeStampItems))

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

@if($hasFreeStampItems && $displayStampDiscountAmount > 0) @lang('app.freeItem') + {{ currency_format($displayStampDiscountAmount, $restaurant->currency_id) }} @lang('app.discount') @elseif($hasFreeStampItems) @lang('app.freeItem') @else {{ currency_format($displayStampDiscountAmount, $restaurant->currency_id) }} @lang('app.discount') @endif

@php $isPaid = $order->isFullyPaid(); $isCancelled = in_array($order->status, ['canceled', 'cancelled'], true) || (($order->order_status->value ?? null) === 'cancelled'); @endphp @if(!$isPaid) {{ __('loyalty::app.remove') }} ... @endif
@endif @if(!(in_array($order->status, ['canceled', 'cancelled'], true) || (($order->order_status->value ?? null) === 'cancelled'))) @if(($isPointsEnabledForCustomerSite ?? false) && ($customer ?? null)) @if(($availableLoyaltyPoints ?? 0) > 0 || isset($currentTier))

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

{{ __('loyalty::app.pointsBalance') }}
{{ number_format($availableLoyaltyPoints ?? 0) }}
@if(isset($currentTier) && $currentTier) @include('loyalty::components.tier-display', [ 'currentTier' => $currentTier, 'nextTier' => $nextTier ?? null, 'pointsToNextTier' => $pointsToNextTier ?? null, 'tierProgress' => $tierProgress ?? 0, 'availableLoyaltyPoints' => $availableLoyaltyPoints ?? 0 ]) @elseif(($availableLoyaltyPoints ?? 0) > 0)
{{ __('loyalty::app.noTierAssigned') }}
@endif
@endif @endif @if(($isPointsEnabledForCustomerSite ?? false) && ($customer ?? null)) @php // Check if points are already redeemed (from database or component) $hasRedeemedPoints = ($order->loyalty_points_redeemed ?? 0) > 0 || ($loyaltyPointsRedeemed ?? 0) > 0; @endphp @if($customer && ($availableLoyaltyPoints ?? 0) > 0 && !$order->isFullyPaid() && !$hasRedeemedPoints)
@lang('loyalty::app.redeemLoyaltyPoints')
@lang('loyalty::app.redeem')
@endif @endif @if(($isStampsEnabledForCustomerSite ?? false) && ($customer ?? null)) @php // Check if stamps are already redeemed (from database or component) // Check for discount amount OR free items $hasStampDiscount = ($order->stamp_discount_amount ?? 0) > 0 || ($stampDiscountAmount ?? 0) > 0; $hasFreeStampItems = $order->items()->where('is_free_item_from_stamp', true)->exists(); $hasRedeemedStamps = $hasStampDiscount || $hasFreeStampItems || (!empty($selectedStampRuleIds ?? [])); // Check if customer has redeemable stamps $hasRedeemableStamps = false; if (!empty($customerStamps)) { $hasRedeemableStamps = collect($customerStamps)->contains(function ($stampData) { return ($stampData['can_redeem'] ?? false) === true; }); } @endphp @if($customer && $hasRedeemableStamps && !$order->isFullyPaid() && !$hasRedeemedStamps)
@lang('loyalty::app.redeemStamps')
@lang('loyalty::app.redeem')
@endif @endif @endif