<?php
    $subtotal = Cart::instance('shopping')->subtotal();
    $subtotal = str_replace([',', '.00'], '', $subtotal);
    $subtotal = (float) $subtotal;
?>
<div class="sidebar-cart-header">
    <button type="button" class="sidebar-cart-close" onclick="closeSidebarCart()" aria-label="বন্ধ করুন">
        <i class="fa-solid fa-times"></i>
    </button>
    <h3 class="sidebar-cart-title">কার্ট</h3>
</div>
<div class="sidebar-cart-body">
    <?php $__empty_1 = true; $__currentLoopData = Cart::instance('shopping')->content(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <?php
            $oldPrice = (float) ($item->options->old_price ?? 0);
            $itemTotal = $item->price * $item->qty;
            $originalTotal = $oldPrice > 0 ? $oldPrice * $item->qty : $itemTotal;
            $savings = $originalTotal - $itemTotal;
        ?>
        <div class="sidebar-cart-item" data-rowid="<?php echo e($item->rowId); ?>">
            <a href="<?php echo e(route('product', $item->id)); ?>" class="sidebar-cart-item-img">
                <img src="<?php echo e(asset($item->options->image ?? 'public/uploads/default.webp')); ?>" alt="<?php echo e($item->name); ?>">
            </a>
            <div class="sidebar-cart-item-details">
                <a href="<?php echo e(route('product', $item->id)); ?>" class="sidebar-cart-item-title"><?php echo e(Str::limit($item->name, 35)); ?></a>
                <p class="sidebar-cart-item-price">৳<?php echo e(number_format($item->price, 0)); ?> × <span class="sidebar-qty-val"><?php echo e($item->qty); ?></span> = ৳<span class="sidebar-item-total"><?php echo e(number_format($itemTotal, 0)); ?></span></p>
                <div class="sidebar-cart-qty">
                    <button type="button" class="sidebar-qty-btn cart_decrement" data-id="<?php echo e($item->rowId); ?>">−</button>
                    <span class="sidebar-qty-num"><?php echo e($item->qty); ?></span>
                    <button type="button" class="sidebar-qty-btn cart_increment" data-id="<?php echo e($item->rowId); ?>">+</button>
                </div>
                <?php if($savings > 0): ?>
                    <p class="sidebar-cart-item-savings">আপনি সেভ করেছেন ৳<?php echo e(number_format($savings, 0)); ?></p>
                <?php endif; ?>
                <button type="button" class="sidebar-cart-item-remove cart_remove" data-id="<?php echo e($item->rowId); ?>" title="মুছে ফেলুন">
                    <i class="fa-solid fa-trash"></i>
                </button>
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <div class="sidebar-cart-empty">
            <i class="fa-solid fa-cart-shopping"></i>
            <p>আপনার কার্টে কোন পণ্য নেই</p>
        </div>
    <?php endif; ?>
</div>
<div class="sidebar-cart-footer">
    <div class="sidebar-cart-total">
        <span class="sidebar-cart-total-label">কার্ট টোটাল</span>
        <span class="sidebar-cart-total-amount">৳<?php echo e(number_format($subtotal, 0)); ?></span>
    </div>
    <a href="<?php echo e(route('customer.checkout')); ?>" class="sidebar-cart-checkout-btn">শপিং ব্যাগ</a>
</div>
<?php /**PATH /home/creativedesignbd/ecommerce4.creativedesign.com.bd/resources/views/frontEnd/layouts/ajax/sidebar_cart.blade.php ENDPATH**/ ?>