<?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">
                <form method="post" action="<?php echo e(route('checkouting.payment')); ?>" onsubmit="formAction(this)">
                    <?php echo csrf_field(); ?>
                    <h2 class="sec_title text-uppercase color-primary fw-bold mb-5">
                        Order Details
                        <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="inner">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="data-group">
                                            <span class="label color-gray2">   Payment method  </span>
                                            <p class="data mb-0"> <?php echo e(__('web.'.$order_shipping_status)); ?> </p>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="data-group">
                                            <span class="label color-gray2">   Shipping method  </span>
                                            <p class="data mb-0">  <?php echo e($shipping_method); ?>     </p>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="data-group">
                                            <span class="label color-gray2">   Date  </span>
                                            <p class="data mb-0">  <?php echo e($date); ?>     </p>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="data-group">
                                            <div class="in-flex">
                                                <span class="label color-gray2"> Location  </span>
                                            </div>
                                            <p class="data mb-0"> <?php echo e($location); ?> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <h2 class="sec_title text-uppercase color-primary fw-bold my-5">
                                Shopping cart
                                <img src="<?php echo e(url('')); ?>/assets/web/images/title_line.svg" class="d-block " alt="">
                            </h2>
                            <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('checkout.method')); ?>" class="butn white_butn fw-bold">
                                    <i class="fas fa-angle-left me-3"></i>  Back
                                </a>

                                <button type="submit" class="butn primary_butn fw-bold">
                                    checkout <i class="fas fa-angle-right ms-3"></i>
                                </button>
                            </div>
                        </div>
                        <div class="col-lg-3 order_sm_1">
                            <div class="copon_box order_summary mb-5">
                                <h5 class="mb-4 fw-bold">Discount Coupon </h5>
                                <div class="form-group">
                                    <input class="form-control" id="cobon" onchange="calculate()" placeholder=" Copoun   " type="text"/>
                                    <button class="butn primary_butn apply_butn">Apply</button>
                                </div>
                            </div>
                            <div class="copon_box order_summary mb-5">
                                <h5 class="mb-4 fw-bold">Notes with the order </h5>
                                <div class="form-group">
                                    <textarea rows="6" name="note" class="form-control" ></textarea>
                                </div>
                            </div>
                            <div class="order_summary">
                                <div class="order_summary_inner">
                                    <h5 class="mb-4 fw-bold">Payment Details</h5>
                                    <div class="item in-flex mb-3">
                                        <span class="label">Tax</span>
                                        <h6 class="price"><b class="color-primary" id="total_tax"></b> <small><?php echo e($currency->abbr); ?></small></h6>
                                    </div>
                                    <div class="item in-flex mb-3">
                                        <span class="label">Subtotal</span>
                                        <h6 class="price"><b class="color-primary" id="product_total"></b> <small><?php echo e($currency->abbr); ?></small></h6>
                                    </div>
                                    <div class="item in-flex mb-3">
                                        <span class="label">Shipping</span>
                                        <h6 class="price"><b class="color-primary" id="total_shipping"></b> <small><?php echo e($currency->abbr); ?></small></h6>
                                    </div>
                                    <div class="item in-flex mb-0">
                                        <span class="label">Total</span>
                                        <h6 class="price"><b class="color-primary" id="total_order"></b> <small><?php echo e($currency->abbr); ?></small></h6>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </form>
            </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 currency_abbr = "<?php echo e($currency->abbr); ?>"
    </script>
    <script>
        let url_calculate_order = "<?php echo e(route('order.calculate')); ?>"
        setTimeout(function(){
            calculate()
        }, 700);

        $(".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);
                }
            })
        }
        function calculate()
        {
            let cobon = $('#cobon').val()
            $.ajax
            ({
                url : url_calculate_order,
                type: "GET",
                data: 'cobon='+cobon,
                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);
                        if(product.discount != 0)
                        {
                            $('#product_cost_total'+product.cart_id).html(' <b class="color-primary" id="product_total'+product.cart_id+'">'+product.product_total+' </b> <small class="fs-6">'+currency_abbr+'</small><del>'+ (product.product_total + product.discount) +' '+currency_abbr+'</del>');
                        }
                        else
                        {
                            $('#product_cost_total'+product.cart_id).html(' <b class="color-primary" id="product_total'+product.cart_id+'">'+product.product_total+' </b> <small class="fs-6">'+currency_abbr+'</small>');
                        }
                    });
                    $('#product_total').html(data.product_total);
                    $('#total_tax').html(data.total_tax);
                    $('#total_shipping').html(data.total_shipping);
                    $('#total_order').html(data.total_order);
                }
                ,error:function(data)
                {
                    toasterError(Object.values(data.responseJSON.errors)[0]);
                }
            })
        }
    </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/orders/checkout_payment.blade.php ENDPATH**/ ?>