<?php $__env->startSection('content'); ?>

    <main>
        <!-- Start section -->
    <?php echo $__env->make('web.layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>


        <section class="cart_pg section">
            <div class="container">
                <h2 class="sec_title text-uppercase color-primary fw-bold mb-5">
                    Shopping cart
                    <img src="<?php echo e(url('')); ?>/assets/web/images/title_line.svg" class="d-block " alt="">
                </h2>
                <div class="row">
                    <div class="col-lg-9">
                        <div class="table-responsive">
                            <?php echo $__env->make('web.pages.components.cart.cart', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                        </div>
                        <div class="in-flex mt-5 flex-wrap" >
                            <a href="<?php echo e(route('products')); ?>" class="butn white_butn fw-bold">
                                Continue Shopping <i class="fas fa-angle-right ms-3"></i>
                            </a>

                            <a href="<?php echo e(route('checkout.location')); ?>" class="butn primary_butn fw-bold">
                                Complete Order <i class="fas fa-angle-right ms-3"></i>
                            </a>
                        </div>
                    </div>
                    <div class="col-lg-3 order_sm_1">
                        <div class="order_summary">
                            <div class="order_summary_inner">
                                <h5 class="mb-4 fw-bold">Payment Details</h5>
                                <div class="item in-flex mb-0">
                                    <span class="label">Total</span>
                                    <h6 class="price"><b class="color-primary" id="order_total"><?php echo e($total); ?></b> <small><?php echo e($currency->abbr); ?></small></h6>
                                </div>

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


    <!-- Start section -->
        <?php echo $__env->make('web.layouts.newsletter', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    </main>
<?php $__env->startSection('inject_js'); ?>
    <script>
        let url_edit_cart = "<?php echo e(url(getCurrentLocale().'/cart/edit')); ?>"
        let url_delete_cart = "<?php echo e(url(getCurrentLocale().'/cart/delete')); ?>"
        let url_calculate_order = "<?php echo e(route('order.calculate')); ?>"
    </script>
    <script>
        function calculate()
        {
            $.ajax
            ({
                url : url_calculate_order,
                type: "GET",
                data: '',
                dataType:'json',
                success:function(data)
                {
                    $.each(data.products, function (key, product) {
                        $('#cart'+product.cart_id).html(product.count);
                        $('#product_cost'+product.cart_id).html(product.product_cost);
                        $('#tax_value'+product.cart_id).html(product.tax);
                        $('#product_total'+product.cart_id).html(product.product_total);
                    });
                    $('#order_total').html(data.product_total);
                }
                ,error:function(data)
                {
                    toasterError(Object.values(data.responseJSON.errors)[0]);
                }
            })
        }
        $(".qt-plus").click(function() {
            let newVal = parseInt($(this).parent().children(".qt").html()) + 1;
            let cart_id = $(this).attr('data-id');
            $.ajax
            ({
                url : url_edit_cart+'/'+cart_id,
                type: "POST",
                headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                data: 'count='+newVal+'&status=plus',
                dataType:'json',
                success:function(data)
                {
                    toasterSuccess(data.message);
                    calculate()
                }
                ,error:function(data)
                {
                    toasterError(Object.values(data.responseJSON.errors)[0]);
                }
            })
        });

        $(".qt-minus").click(function() {

            child = $(this).parent().children(".qt");

            if (parseInt(child.html()) > 1) {
                let newVal = parseInt(child.html()) - 1;
                let cart_id = $(this).attr('data-id');
                $.ajax
                ({
                    url : url_edit_cart+'/'+cart_id,
                    type: "POST",
                    headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                    data: 'count='+newVal+'&status=minus',
                    dataType:'json',
                    success:function(data)
                    {
                        toasterSuccess(data.message);
                        calculate()
                    }
                    ,error:function(data)
                    {
                        toasterError(Object.values(data.responseJSON.errors)[0]);
                    }
                })

            }

            $(this).parent().children(".full-price").addClass("minused");

        });
        function deleteCart(elem)
        {
            let cart_id = $(elem).attr('data-id');
            $.ajax
            ({
                url : url_delete_cart+'/'+cart_id,
                type: 'GET',
                data: '',
                success:function(data)
                {
                    $(elem).closest('.cart_row').fadeOut(1000);
                    $('#order_total').html(data.data);
                }
            })
        }
    </script>
<?php $__env->stopSection(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('web.layouts.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/city/resources/views/web/pages/cart/cart.blade.php ENDPATH**/ ?>