@php
$itemSubtotal = 0; // Pure items + extras (before commission)
$adminCommissionTotal = 0;
$taxDetails = [];
$fixedTaxTracker = [];
// Commission settings from controller
$commissionEnabled = $commissionSettings['enabled'] ?? false;
$commissionType = $commissionSettings['type'] ?? 'Percent';
$commissionValue = $commissionSettings['value'] ?? 0;
$cart = session('cart', []);
@endphp
@foreach($cart as $item)
@php
$variantPrice = $item['variant_info']['variant_price'] ?? 0;
$basePrice = $variantPrice > 0 ? $variantPrice : ($item['original_base_price'] ?? 0);
$extrasPrice = $item['extras_price'] ?? 0;
$quantity = $item['quantity'] ?? 1;
// Price for this cart item (base + extras) × quantity
$itemTotal = ($basePrice + $extrasPrice) * $quantity;
$itemSubtotal += $itemTotal;
// Calculate admin commission on the item total
if ($commissionEnabled && $commissionValue > 0) {
if ($commissionType === 'Percent') {
$adminCommissionTotal += $itemTotal * ($commissionValue / 100);
} else { // Fixed
$adminCommissionTotal += $commissionValue * $quantity;
}
}
// Taxes are applied later on the taxable base (items + commission)
// We will process them after calculating the full taxable subtotal
@endphp
@endforeach
@php
// Taxable base = items subtotal + admin commission
$taxableSubtotal = $itemSubtotal + $adminCommissionTotal + $cart['packagingCharge'] + $cart['platformCharge'];
$grandTotal = $taxableSubtotal + $cart['totalTax'];
@endphp
| {{ trans('lang.sub_total') }} |
{{ number_format($itemSubtotal, 2) }}
|
@if($commissionEnabled && $adminCommissionTotal > 0)
|
{{ trans('lang.admin_commission') }}
@if($commissionType === 'Percent') ({{ $commissionValue }}%) @else ({{ trans('lang.coupon_fixed') }}) @endif
|
{{ number_format($adminCommissionTotal, 2) }}
|
@endif
@if($cart['packagingCharge'] && $cart['packagingCharge'] > 0)
|
{{ trans('lang.packaging_charge') }}
|
{{ number_format($cart['packagingCharge'], 2) }}
|
@endif
@if($cart['platformCharge'] && $cart['platformCharge'] > 0)
|
{{ trans('lang.platform_charge') }}
|
{{ number_format($cart['platformCharge'], 2) }}
|
@endif
@if(!empty($cart['taxBreakdownGrouped']))
{{-- Item-level --}}
@if(!empty($cart['taxBreakdownGrouped']['item']))
|
{{ trans('lang.tax_on_item_total') }}:
|
{{ number_format(array_sum($cart['taxBreakdownGrouped']['item']), $cart['decimal_degits'] ?? 2) }}
|
@endif
{{-- Order-level --}}
@if(!empty($cart['taxBreakdownGrouped']['order']))
|
{{ trans('lang.tax_on_order_total') }}:
|
{{ number_format(array_sum($cart['taxBreakdownGrouped']['order']), $cart['decimal_degits'] ?? 2) }}
|
@endif
{{-- Packaging-level --}}
@foreach($cart['taxBreakdownGrouped']['packaging'] ?? [] as $title => $amount)
|
{{ $title }} {{ trans('lang.tax_on_packaging_fee') }}:
|
{{ number_format($amount, $cart['decimal_degits'] ?? 2) }}
|
@endforeach
{{-- Platform-level --}}
@foreach($cart['taxBreakdownGrouped']['platform'] ?? [] as $title => $amount)
|
{{ $title }} {{ trans('lang.tax_on_platform_fee') }}:
|
{{ number_format($amount, $cart['decimal_degits'] ?? 2) }}
|
@endforeach
@endif
| {{ trans('lang.total_tax') }} |
{{ number_format($cart['totalTax'], $cart['decimal_degits'] ?? 2) }}
|
| {{ trans('lang.total_amount') }} |
{{ number_format($grandTotal, 2) }}
|