@if(count($carts))
    <div class="table-responsive">
        <table class="table mt-5">
            <thead>
            <tr>
                <th>{{__('web.product_image')}}</th>
                <th>{{__('web.product_name')}}</th>
                @if($route == 'cart')
                    <th>{{__('web.product_code')}}</th>
                @endif
                <th>{{__('web.quantity')}}</th>
                <th>{{__('web.cost')}}</th>
                @if($route == 'cart')
                    @if($settings['tax_valid'])
                        <th>{{__('web.tax')}}</th>
                    @endif
                @endif
                <th>{{__('web.total')}}</th>
                @if($route == 'cart')
                    <th></th>
                @endif
            </tr>
            </thead>
            <tbody>
            @foreach($carts as $row)
                <tr class="cart_card_row">
                    <td>
                        <img src="{{$row['product_image']}}" class="prodImg" alt=""/>
                    </td>
                    <td>{{$row['product_name']}}</td>
                    @if($route == 'cart')
                        <td>{{$row['product_code']}}</td>
                    @endif
                    <td>
                        <div class="qty-container">
                            <button class=" btn-light" onclick="qtyDecrease(this)" action-id="{{route('cart.update',$row['id'])}}" data-id="{{$row['id']}}" type="button"><i class="fa fa-minus"></i></button>
                            <input type="text" id="qty{{$row['id']}}" name="qty" value="{{$row['count']}}" data-id="{{$row['id']}}" count-id="{{$row['count']}}" class="input-qty"/>
                            <button class=" btn-light" onclick="qtyIncrease(this)" action-id="{{route('cart.update',$row['id'])}}" data-id="{{$row['id']}}" type="button"><i class="fa fa-plus"></i></button>
                        </div>
                    </td>
                    <td>{{$row['product_cost']}} {{__('web.sar')}}</td>
                    @if($route == 'cart')
                        @if($settings['tax_valid'])
                            <td>{{$row['tax_cost']}} {{__('web.sar')}}</td>
                        @endif
                    @endif
                        <td>
                            <b>{{$route == 'cart' ? ($row['product_cost'] + $row['tax_cost']) : $row['product_cost']}} {{__('web.sar')}}</b>
                        </td>
                    @if($route == 'cart')
                        <td>
                            <button type="button" onclick="deleteCart(this)" action-id="{{route('cart.destroy',$row['id'])}}" class="delete_butn butn sm_butn rounded-circle gray_butn">
                                <i class="fal fa-trash-alt mx-0"></i>
                            </button>
                        </td>
                    @endif
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    <div class="summary_box col-lg-4 ms-auto">
        <div class="item d-flex justify-content-between mb-3">
            <p class="label">{{__('web.cost')}}</p>
            <span class="color-primary">{{$total_products}} {{__('web.sar')}}</span>
        </div>
        @if($route != 'cart')
            @if($discount != 0)
                <div class="item d-flex justify-content-between mb-3">
                    <p class="label">{{__('web.discount')}}</p>
                    <span class="color-primary">{{$discount}} {{__('web.sar')}}</span>
                </div>
            @endif
        @endif
        @if($settings['tax_valid'])
            <div class="item d-flex justify-content-between mb-3">
                <p class="label">{{__('web.tax')}}</p>
                <span class="color-primary">{{$total_tax}} {{__('web.sar')}}</span>
            </div>
        @endif
        @if($route != 'cart')
            <div class="item d-flex justify-content-between mb-3">
                <p class="label">{{__('web.shipping_cost')}}</p>
                <span class="color-primary">{{$shipping_cost}} {{__('web.sar')}}</span>
            </div>
        @endif
        @if($route != 'cart')
            @if($on_hand_cost != 0)
                <div class="item d-flex justify-content-between mb-3">
                    <p class="label">{{__('web.on_hand_cost')}}</p>
                    <span class="color-primary">{{$on_hand_cost}} {{__('web.sar')}}</span>
                </div>
            @endif
        @endif
        <div class="item d-flex justify-content-between mb-3">
            <p class="label">{{__('web.full_total')}}</p>
            <span class="color-primary ">{{$route == 'cart' ? $total_products_tax : $total}} {{__('web.sar')}}</span>
        </div>
    </div>

    <script src="{{url('')}}/assets/web/js/custom/product.js"></script>

@else
    @include('web.pages.components.not_found',['message'=>__('web.not_found_product_cart')])
@endif
