featured_image)) {
if (is_numeric($booking->featured_image)) {
$featured_image_url = wp_get_attachment_url((int) $booking->featured_image) ?: '';
} else {
$featured_image_url = $booking->featured_image;
}
}
?>
trip_title); ?>
trip_average_rating) && $booking->trip_review_count >= 0) : ?>
trip_average_rating);
$has_half = ($booking->trip_average_rating - $filled_stars) >= 0.5;
for ($i = 1; $i <= 5; $i++) :
$class = $i <= $filled_stars ? 'yatra-star-filled' : ($has_half && $i === $filled_stars + 1 ? 'yatra-star-half' : '');
?>
trip_average_rating, 1)); ?>
trip_review_count, 'yatra')), (int) $booking->trip_review_count);
?>
starting_location)) : ?>
starting_location); ?>
ending_location) && $booking->ending_location !== $booking->starting_location) : ?>
→ ending_location); ?>
trip_destinations_list)) : ?>
trip_activities_list)) : ?>
trip_categories_list)) : ?>
trip_attributes_list)) : ?>
travelers)) : ?>
travelers as $index => $traveler) :
$traveler_name = trim(($traveler['first_name'] ?? '') . ' ' . ($traveler['last_name'] ?? ''));
?>
subtotal ?? $booking->total_amount);
$discount_amount = (float) ($booking->discount_amount ?? 0);
$itinerary_costs_total = (float) ($booking->itinerary_costs_total ?? 0);
$tax_amount = (float) ($booking->tax_amount ?? 0);
$tax_inclusive = !empty($booking->tax_inclusive);
$total_amount = (float) $booking->total_amount;
$amount_paid = (float) ($booking->amount_paid ?? 0);
$amount_due = (float) ($booking->amount_due ?? 0);
// ── Tax breakdown (built first so it can gate later rows) ─
$tax_breakdown = [];
if (!empty($booking->tax_details)) {
$taxes = json_decode($booking->tax_details, true) ?: [];
foreach ($taxes as $tax) {
$tax_breakdown[] = [
'name' => $tax['name'] ?? __('Tax', 'yatra'),
'rate' => (float) ($tax['rate'] ?? 0),
'amount' => (float) ($tax['amount'] ?? 0),
];
}
} elseif ($tax_amount > 0) {
$tax_breakdown[] = [
'name' => __('Tax', 'yatra'),
'rate' => (float) ($booking->tax_rate ?? 0),
'amount' => $tax_amount,
];
}
// ── Itinerary costs ───────────────────────────────────────
$itinerary_costs = [];
if (!empty($booking->itinerary_costs)) {
$itinerary_costs = json_decode($booking->itinerary_costs, true) ?: [];
}
// ── Additional services ───────────────────────────────────
$raw_services = apply_filters('yatra_booking_get_services', [], (int) ($booking->id ?? 0));
$selected_services = [];
if (!empty($raw_services) && is_array($raw_services)) {
foreach ($raw_services as $s) {
$arr = is_array($s) ? $s : (array) $s;
if (!isset($arr['selected']) || !empty($arr['selected'])) {
$selected_services[] = $arr;
}
}
}
$services_total = 0.0;
foreach ($selected_services as $s) {
$services_total += (float) ($s['total_price'] ?? $s['calculated_price'] ?? $s['total_cost'] ?? $s['amount'] ?? $s['unit_price'] ?? $s['price'] ?? 0);
}
// ── Derived amounts ───────────────────────────────────────
// base_trip_cost: the trip price without services (services are embedded in db_subtotal by Pro)
$base_trip_cost = $db_subtotal - $services_total;
// taxable_amount: what tax is calculated on
$taxable_amount = max(0.0, $db_subtotal - $discount_amount) + $itinerary_costs_total;
$has_services = !empty($selected_services);
$has_discount = $discount_amount > 0;
$has_itinerary = !empty($itinerary_costs) && $itinerary_costs_total > 0;
$has_tax = !empty($tax_breakdown);
$show_taxable_row = $has_tax && ($has_discount || $has_itinerary);
?>
currency)); ?>
+
currency, false)); ?>
currency)); ?>
-currency)); ?>
currency)); ?>
currency)); ?>
+
0): ?>
(%)
+currency)); ?>
currency)); ?>
0 ? ' (' . esc_html($tax['rate']) . '%)' : '',
esc_html(yatra_format_price($tax['amount'], $booking->currency))
);
?>
0): ?>
currency)); ?>
0): ?>
currency)); ?>
payment_gateway))); ?>
findLatestByBookingId((int) $booking->id);
if ($latestPayment && in_array($latestPayment->status, ['completed', 'paid'], true)) :
$invoiceToken = \Yatra\Controllers\PaymentGatewayController::issueInvoiceToken(
(int) $latestPayment->id,
(int) ($latestPayment->booking_id ?? $booking->id)
);
$invoiceUrl = add_query_arg(
[
'download' => '1',
'invoice_token' => $invoiceToken,
],
rest_url('yatra/v1/payment/' . (int) $latestPayment->id . '/invoice')
);
?>