Order Summary
@php
$cart = session()->get('cart', []);
$subtotal = 0;
foreach($cart as $item) {
$subtotal += $item['price'] * $item['quantity'];
}
$discount = 0;
if(session()->has('coupon')) {
$coupon = \App\Models\Coupon::where('code', session('coupon'))->first();
if($coupon) {
if($coupon->type == 'fixed') $discount = $coupon->value;
else $discount = ($subtotal * $coupon->value) / 100;
}
}
$shipping = 50;
$total = $subtotal - $discount + $shipping;
@endphp
Subtotal: ${{ number_format($subtotal, 2) }}
@if($discount > 0)
Discount: -${{ number_format($discount, 2) }}
@endif
Shipping: ${{ number_format($shipping, 2) }}
Total: ${{ number_format($total, 2) }}