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

    <h4 class="mb-4 font-weight-bold">My Orders</h4>

    <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
    <div class="card shadow-sm mb-4">
        <div class="card-header bg-light d-flex justify-content-between">
            <div>
                <strong>Order #<?php echo e($order->order_number); ?></strong><br>
                <small class="text-muted">
                    Placed on <?php echo e($order->created_at->format('d M Y, h:i A')); ?>

                </small>
            </div>
            <div>
                <span class="badge badge-info text-uppercase">
                    <?php echo e($order->status); ?>

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

        <div class="card-body">
            <div class="row">

                
                <div class="col-md-6">
                    <h6 class="font-weight-bold">Items</h6>

                    <?php $__currentLoopData = $order->cart_info; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="border rounded p-2 mb-2">

                            <?php if($item->item_type === 'product' && $item->product): ?>
                                <strong><?php echo e($item->product->title); ?></strong>
                                <div class="text-muted small">
                                    Qty: <?php echo e($item->quantity); ?> × ₹<?php echo e(number_format($item->price,2)); ?>

                                </div>
                            <?php endif; ?>

                            <?php if($item->item_type === 'subscription' && $item->subscription): ?>
                                <strong><?php echo e($item->subscription->package_name); ?></strong>
                                <div class="text-muted small">
                                    Subscription Package
                                </div>
                            <?php endif; ?>

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

                
                <div class="col-md-6">

                    
                    <h6 class="font-weight-bold">Payment Info</h6>
                    <table class="table table-sm">
                        <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_payment_id): ?>
                        <tr>
                            <td>Payment ID</td>
                            <td class="text-right small">
                                <?php echo e($order->razorpay_payment_id); ?>

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

                    
                    <h6 class="font-weight-bold mt-3">Shipping Info</h6>
                    <table class="table table-sm">
                        <tr>
                            <td>Name</td>
                            <td class="text-right">
                                <?php echo e($order->first_name); ?> <?php echo e($order->last_name); ?>

                            </td>
                        </tr>
                        <tr>
                            <td>Phone</td>
                            <td class="text-right"><?php echo e($order->phone); ?></td>
                        </tr>
                        <tr>
                            <td>Address</td>
                            <td class="text-right small">
                                <?php echo e($order->address1); ?><br>
                                <?php echo e($order->address2); ?><br>
                                <?php echo e($order->country); ?> - <?php echo e($order->post_code); ?>

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

                    
                    <h6 class="font-weight-bold mt-3">Order Summary</h6>
                    <table class="table table-sm">
                        <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(optional($order->shipping)->price ?? 0,2)); ?>

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

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

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

        <div class="card-footer text-right">
            <a href="<?php echo e(route('user.order.show',$order->id)); ?>" class="btn btn-sm btn-primary">
                View Details
            </a>
        </div>
    </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <div class="alert alert-info">No orders found.</div>
    <?php endif; ?>

    <div class="d-flex justify-content-end">
        <?php echo e($orders->links()); ?>

    </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/index.blade.php ENDPATH**/ ?>