<?php $__env->startSection('title','Order Details'); ?>

<?php $__env->startSection('main-content'); ?>
<div class="container-fluid">

    
    <div class="card shadow-sm mb-4">
        <div class="card-body d-flex justify-content-between align-items-center">
            <div>
                <h5 class="mb-1">Order #<?php echo e($order->order_number); ?></h5>
                <small class="text-muted">
                    Placed on <?php echo e($order->created_at->format('d M Y, h:i A')); ?>

                </small>
            </div>
            <div>


<?php if($order->shiprocket_invoice_url): ?>
<a href="<?php echo e($order->shiprocket_invoice_url); ?>"
target="_blank"
class="btn btn-sm btn-success">
Download Invoice
</a>
<?php else: ?>
<span class="text-muted">
Invoice not generated yet
</span>
<?php endif; ?>


            </div>
        </div>
    </div>

    <div class="row">

        
        <div class="col-lg-8">

            
            <div class="card shadow-sm mb-4">
                <div class="card-header bg-light">
                    <strong>Order Items</strong>
                </div>
                <div class="card-body">

                    <?php $__currentLoopData = $order->cart_info; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="d-flex justify-content-between border-bottom py-2">

                        <div>
                            <?php if($item->item_type === 'product' && $item->product): ?>
                            <div class="font-weight-bold">
                                <?php echo e($item->product->title); ?>

                            </div>
                            <small class="text-muted">
                                Product Item
                            </small>
                            <?php endif; ?>

                            <?php if($item->item_type === 'subscription' && $item->subscription): ?>
                            <div class="font-weight-bold">
                                <?php echo e($item->subscription->package_name); ?>

                            </div>
                            <small class="text-muted">
                                Subscription Package
                            </small>
                            <?php endif; ?>
                        </div>

                        <div class="text-right">
                            Qty: <?php echo e($item->quantity); ?> <br>
                            ₹<?php echo e(number_format($item->price,2)); ?>

                        </div>

                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                </div>
            </div>

            
            <div class="card shadow-sm mb-4">
                <div class="card-header bg-light">
                    <strong>Shipping Information</strong>
                </div>
                <div class="card-body">
                    <p class="mb-1 font-weight-bold">
                        <?php echo e($order->first_name); ?> <?php echo e($order->last_name); ?>

                    </p>
                    <p class="mb-1"><?php echo e($order->phone); ?></p>
                    <p class="mb-1"><?php echo e($order->email); ?></p>
                    <p class="mb-0">
                        <?php echo e($order->address1); ?>, <?php echo e($order->address2); ?><br>
                        <?php echo e($order->country); ?> - <?php echo e($order->post_code); ?>

                    </p>
                </div>
            </div>

        </div>

        
        <div class="col-lg-4">

            
            <div class="card shadow-sm mb-4">
                <div class="card-header bg-light">
                    <strong>Order Summary</strong>
                </div>
                <div class="card-body">
                    <table class="table table-sm mb-0">
                        <tr>
                            <td>Subtotal</td>
                            <td class="text-right">
                                ₹<?php echo e(number_format($order->sub_total,2)); ?>

                            </td>
                        </tr>
                        <tr>
                            <td>Delivery</td>
                            <td class="text-right">
                                ₹<?php echo e(number_format($order->delivery_charge ?? 0,2)); ?>

                            </td>
                        </tr>
                        <tr class="font-weight-bold">
                            <td>Total</td>
                            <td class="text-right">
                                ₹<?php echo e(number_format($order->total_amount,2)); ?>

                            </td>
                        </tr>
                    </table>
                </div>
            </div>

            
            <div class="card shadow-sm mb-4">
                <div class="card-header bg-light">
                    <strong>Payment Information</strong>
                </div>
                <div class="card-body">
                    <table class="table table-sm mb-0">
                        <tr>
                            <td>Method</td>
                            <td class="text-right text-capitalize">
                                <?php echo e($order->payment_method); ?>

                            </td>
                        </tr>
                        <tr>
                            <td>Status</td>
                            <td class="text-right">
                                <span class="badge badge-success">
                                    <?php echo e($order->payment_status); ?>

                                </span>
                            </td>
                        </tr>

                        <?php if($order->razorpay_order_id): ?>
                        <tr>
                            <td>Razorpay Order ID</td>
                            <td class="text-right small">
                                <?php echo e($order->razorpay_order_id); ?>

                            </td>
                        </tr>
                        <?php endif; ?>

                        <?php if($order->razorpay_payment_id): ?>
                        <tr>
                            <td>Payment ID</td>
                            <td class="text-right small">
                                <?php echo e($order->razorpay_payment_id); ?>

                            </td>
                        </tr>
                        <?php endif; ?>
                    </table>
                </div>
            </div>

            
            <div class="card shadow-sm">
                <div class="card-body text-center">

                    <div class="mb-2">Order Status</div>

                    <span class="badge badge-info text-uppercase px-3 py-2">
                        <?php echo e($order->status); ?>

                    </span>


                    
                    <?php if($order->exchange_requested): ?>

                    <div class="mt-3">
                        <div class="text-muted small">Exchange Status</div>

                        <span class="badge badge-warning">
                            <?php echo e($order->exchange_status ?? 'Requested'); ?>

                        </span>
                    </div>

                    <?php endif; ?>


                    
                    <?php if(
                    $order->status == 'delivered' &&
                    !$order->exchange_requested
                    ): ?>

                    <form method="POST"
                        action="<?php echo e(route('user.order.exchange.request',$order->id)); ?>"
                        class="mt-3">

                        <?php echo csrf_field(); ?>

                        <button class="btn btn-warning btn-sm">
                            Request Exchange
                        </button>

                    </form>

                    <?php endif; ?>

                </div>
            </div>

        </div>

    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('user.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/ecommerce_website/resources/views/user/order/show.blade.php ENDPATH**/ ?>