@php
// Flags from API for bundled rates
$supportsCancellation = $rate['supports_cancellation'] ?? false;
$isNonRefundable = $rate['non_refundable'] ?? false;
$underCancellation = $cancellationPolicy['under_cancellation'] ?? false;
$cancelDate = $cancelByDate ? \Carbon\Carbon::parse($cancelByDate) : null;
$now = \Carbon\Carbon::now();
@endphp
{{-- Step 1: Cannot cancel at all --}}
@if(!$supportsCancellation)
Non-Cancellable
No refund allowed under any circumstance.
{{-- Step 2: Supports cancellation but non-refundable --}}
@elseif($supportsCancellation && $isNonRefundable)
Non-Refundable
No refund will be issued once booked.
{{-- Step 3: Supports cancellation and refundable / partially refundable --}}
@else
@if($underCancellation)
Partially Refundable
Cancellation fee may apply.
@else
Fully Refundable
Before cancellation deadline
@endif
{{-- Cancel by date --}}
@if($cancelDate)
@if($now->lt($cancelDate))
Free cancellation until: {{ $cancelDate->format('M d, Y h:i A') }}
@else
Cancellation deadline passed: {{ $cancelDate->format('M d, Y h:i A') }}
@endif
@endif
{{-- Detailed Cancellation Rules --}}
@if(!empty($cancellationDetails))
Cancellation Charges:
@foreach($cancellationDetails as $rule)
@php
$ruleDate = \Carbon\Carbon::parse($rule['from'])->format('M d, Y h:i A');
if(isset($rule['percent'])) {
$chargeMsg = "{$rule['percent']}% of the total booking amount will be charged.";
} elseif(isset($rule['flat_fee'])) {
$currency = $rule['currency'] ?? '';
$chargeMsg = "A fixed fee of {$currency} " . number_format($rule['flat_fee'], 2) . " will be charged.";
} elseif(isset($rule['nights'])) {
$chargeMsg = "You will be charged the cost of {$rule['nights']} night(s).";
} else {
$chargeMsg = "Charges apply as per policy.";
}
@endphp
From {{ $ruleDate }}: {{ $chargeMsg }}
@endforeach
@endif
{{-- No Show Fee --}}
@if(!empty($noShowFee))
@php
if(isset($noShowFee['percent'])) {
$noShowMsg = "{$noShowFee['percent']}% of the booking amount will be charged if you fail to check in.";
} elseif(isset($noShowFee['flat_fee'])) {
$currency = $noShowFee['currency'] ?? '';
$noShowMsg = "A fixed charge of {$currency} " . number_format($noShowFee['flat_fee'],2) . " will be applied if you fail to check in.";
} elseif(isset($noShowFee['nights'])) {
$noShowMsg = "If you do not arrive, you will be charged for {$noShowFee['nights']} night(s).";
} else {
$noShowMsg = "No-show charges may apply.";
}
@endphp
{{ $noShowMsg }}
@endif
@endif {{-- End Supports cancellation --}}