관리-도구
편집 파일: buycheckout.blade.php
@extends('layouts.appss') @section('content') <main class="py-5"> <div class="container"> <div class="row g-5"> <!-- LEFT: BILLING DETAILS --> <div class="col-lg-7"> <div class="card p-4 shadow-sm rounded-4"> <h4 class="mb-4 fw-bold">Billing Details</h4> <form action="{{ route('buy.place') }}" method="POST" id="checkoutForm"> @csrf <div class="row g-3"> <div class="col-md-6"> <label class="form-label">First Name*</label> <input type="text" name="first_name" class="form-control" required> </div> <div class="col-md-6"> <label class="form-label">Last Name*</label> <input type="text" name="last_name" class="form-control" required> </div> <div class="col-md-12"> <label class="form-label">Country*</label> <input type="text" name="country" class="form-control" placeholder="Enter your country" required> </div> <div class="col-md-12"> <label class="form-label">Street Address*</label> <input type="text" name="address" class="form-control" required> </div> <div class="col-md-6"> <label class="form-label">City*</label> <input type="text" name="city" class="form-control" required> </div> <div class="col-md-6"> <label class="form-label">State*</label> <input type="text" name="state" class="form-control" required> </div> <div class="col-md-6"> <label class="form-label">ZIP Code*</label> <input type="text" name="zip" class="form-control" required> </div> <div class="col-md-6"> <label class="form-label">Phone*</label> <input type="text" name="phone" class="form-control" required> </div> <div class="col-md-12"> <label class="form-label">Email Address*</label> <input type="email" name="email" class="form-control" required> </div> <div class="col-md-12"> <label class="form-label">Order Notes (optional)</label> <textarea name="order_notes" class="form-control" rows="3"></textarea> </div> </div> </div> </div> <!-- RIGHT: ORDER SUMMARY (Single Product) --> <div class="col-lg-5"> <div class="card p-4 shadow-sm rounded-4"> <h4 class="mb-4 fw-bold">Your Order</h4> <div class="border-bottom mb-3 pb-2 d-flex justify-content-between fw-semibold"> <span>Product</span> <span>Subtotal</span> </div> @if($buyNowProduct) @php // ✅ Base total $total = $buyNowProduct['price'] * $buyNowProduct['quantity']; // ✅ Check if color image exists $displayImage = null; if (!empty($buyNowProduct['color_id'])) { $color = \App\Models\ProductColor::with('images')->find($buyNowProduct['color_id']); if ($color && $color->images->isNotEmpty()) { $displayImage = asset('storage/' . $color->images->first()->image); } } // ✅ Fallback to product image if no color image found if (!$displayImage && !empty($buyNowProduct['image'])) { $displayImage = asset('storage/' . $buyNowProduct['image']); } @endphp <div class="d-flex justify-content-between align-items-center mb-3"> <div class="d-flex align-items-center"> <img src="{{ $displayImage }}" alt="{{ $buyNowProduct['title'] }}" width="70" class="me-3 rounded border"> <div> <span class="fw-semibold d-block">{{ $buyNowProduct['title'] }}</span> @if(!empty($buyNowProduct['color_name'])) <small>Color: {{ ucfirst($buyNowProduct['color_name']) }}</small><br> @endif @if($product && $product->product_mode === 'material') <small>Meters: {{ $buyNowProduct['quantity'] }}</small> @else <small>Qty: {{ $buyNowProduct['quantity'] }}</small><br> @if(!empty($buyNowProduct['size'])) <small>Size: {{ strtoupper($buyNowProduct['size']) }}</small> @endif @endif </div> </div> <span>₹{{ number_format($total, 2) }}</span> </div> <hr> <div class="d-flex justify-content-between fw-bold fs-5"> <span>Total</span> <span>₹{{ number_format($total, 2) }}</span> </div> <button type="submit" class="btn btn-dark w-100 mt-4 py-2">Place Order</button> @else <p class="text-danger">No product selected for checkout.</p> @endif </div> </div> </form> </div> </div> </main> @endsection