@php /** * "Add $4.50 more for free delivery" — the progress meter above the cart totals. * * No new styles: this is the order builder's own progress block (.qm-ob-progress, its -bar and * -msg), which already exists to say "spend more to reach a target" and is the only such meter the * product ships. * * Every number comes from OrderService::resolveDeliveryZone(), which decided the fee itself. The * meter therefore cannot disagree with the charge beneath it — the failure this feature exists to * avoid is a bar that promises free delivery while the line below still bills for it. * * @var float $threshold spend needed; 0 means the restaurant makes no offer * @var float|null $remaining how much more, or null when there is no offer / no basket yet * @var bool $applied the fee has actually been waived on this order */ $threshold = (float) ($threshold ?? 0); $remaining = $remaining ?? null; $applied = !empty($applied); // No offer, or nothing to measure against yet. Rendering an empty bar would be worse than none. if ($threshold <= 0 || $remaining === null) { return; } $remaining = max(0.0, (float) $remaining); // At exactly the threshold the offer is MET, not "add 0.00 more" — the boundary case that makes a // meter look broken at the moment it should feel like a win. $reached = $applied || $remaining <= 0.0; // floor(), and capped at 99 until the offer is actually met: round() showed a full bar at 24.99 of // 25.00 while the message still asked for a penny, which reads as a broken meter rather than a // near miss. A full bar means free delivery and nothing else. $pct = $reached ? 100 : min(99, (int) floor((($threshold - $remaining) / $threshold) * 100)); @endphp

@if ($reached) {{ t_raw('cart.free_delivery_reached') }} @else {{ t_raw('cart.free_delivery_remaining', [':amount' => money($remaining)]) }} @endif