@foreach($lpOrdered as $lpIdx => $lpPlan)
@php
$isFeatured = $lpPlan->is_featured;
$prices = $lpPlan->prices->keyBy(
fn($p) => $p->billing_cycle instanceof BillingCycle
? $p->billing_cycle->value
: (string) $p->billing_cycle
);
$monthlyRow = $prices['monthly'] ?? null;
$halfRow = $prices['half_yearly'] ?? null;
$yearlyRow = $prices['yearly'] ?? null;
$monthlyAmt = (float) ($monthlyRow?->price ?? 0);
$halfAmt = (float) ($halfRow?->price ?? 0);
$yearlyAmt = (float) ($yearlyRow?->price ?? 0);
$isFree = $monthlyAmt <= 0;
$halfPerMo = $halfAmt > 0 ? round($halfAmt / 6, 2) : 0;
$yearPerMo = $yearlyAmt > 0 ? round($yearlyAmt / 12, 2) : 0;
$halfNote = $halfRow?->discount
? __(':d% off — :c:a billed every 6 months', ['d' => $halfRow->discount, 'c' => $currencyCode, 'a' => number_format($halfAmt, siteDecimalPlaces())])
: ($halfAmt > 0 ? __(':c:a billed every 6 months', ['c' => $currencyCode, 'a' => number_format($halfAmt, siteDecimalPlaces())]) : '');
$yearNote = $yearlyRow?->discount
? __(':d% off — :c:a billed yearly', ['d' => $yearlyRow->discount, 'c' => $currencyCode, 'a' => number_format($yearlyAmt, siteDecimalPlaces())])
: ($yearlyAmt > 0 ? __(':c:a billed yearly', ['c' => $currencyCode, 'a' => number_format($yearlyAmt, siteDecimalPlaces())]) : '');
$planIcon = match(true) {
$isFree => 'fas fa-seedling',
$isFeatured => 'fas fa-crown',
default => 'fas fa-rocket',
};
if ($isFree) {
$badgeVariant = 'free';
$badgeText = $lpPlan->plan_badge ?: __('Free Forever');
} elseif ($isFeatured) {
$badgeVariant = 'featured';
$badgeText = $lpPlan->plan_badge ?: __('Most Popular');
} elseif ($lpPlan->plan_badge) {
$badgeVariant = 'pro';
$badgeText = $lpPlan->plan_badge;
} else {
$badgeVariant = null;
$badgeText = null;
}
if ($isFree) {
$ctaLabel = __('Get Started — Free');
} elseif ($lpPlan->trial_days > 0) {
$ctaLabel = __('Start :d-Day Free Trial', ['d' => $lpPlan->trial_days]);
} else {
$ctaLabel = __('Get :name', ['name' => $lpPlan->name]);
}
@endphp
@if($isFeatured)
@endif
{{-- Plan identity --}}
{{ $lpPlan->description ?: __('Access to core platform features.') }}
{{-- Price --}}
@if($isFree)
{{ __('Free') }}
{{ __('forever') }}
@else
{{ $currencyCode }}
{{ number_format($monthlyAmt, siteDecimalPlaces()) }}
/{{ __('mo') }}
@endif
{{-- Trial pill --}}
@if($lpPlan->trial_days > 0)
{{ $lpPlan->trial_days }}-{{ __('day free trial') }}
@endif
{{-- CTA --}}
{{ $ctaLabel }}
@if(! $isFree)
@endif
{{-- Features --}}
@if($lpPlan->features->isNotEmpty())
{{ __("What's included") }}
@foreach($lpPlan->features as $lpFeat)
-
{{ $lpFeat->feature_label }}
@if(! $lpFeat->isToggle())
{{ $lpFeat->isUnlimited() ? __('Unlimited') : $lpFeat->feature_value }}
@endif
@endforeach
@endif
@endforeach