
<div class="card shadow-none" style="margin-bottom:0.8rem;">

  <div class="card-header d-flex align-items-center justify-content-between">
        <h6 class="mb-0">Total Products in Cart <i class="bi bi-cart"></i> ({!! isset($data['products']) ? count($data['products']) : '0' !!})</h6>
        <button class="btn btn-primary float-left" id="checkout" > </button>
 </div>
    
<div class="card-body pb-0">
    <div class="table-responsive">
        <table id="example" class="table table-bordered align-middle" style="width:100%">
            <thead class="table-light">
                <tr>
                    <th class="text-start" style="text-align: right">Item Details </th>
                    <th >Rate Calculation on </th>
                    <th >Item QTY</th>
                    <th >Gross Weight</th>
                    <th >Rate</th>
                    <th>TAX </th>
                    <th >AMOUNT</th>
                    <th class="thbutton">Delete</th>                                   
                </tr>
            </thead>
            <tbody>
                @php
                $i = 1;
                $product_price = 0;
                @endphp
                @if (isset($data['products']) && count($data['products']) > 0)
                @foreach ($data['products'] as $key => $list)
                <tr class="cart-products" data-id="{{ $list['product_id'] }}">
                    <td class="text-start">{{ $list['product'] ?? '' }} 
                    </td>
                     <td class="text-center" name="rate_calculation_update" id="rate_calculation_update"   >
                       {{ $list['rate_calculation_type_name'] ?? '' }}
                    </td>
                    <td >
                     <input type="number" name="item_qty_update" data-id="{{ $list['product_id'] }}" data-rate-cal = "{{ $list['rate_calculation_type_id'] ?? '' }}" class="form-control bg-white" value="{{ convertDecimelPoint($list['item_qty'] ?? '') }}" placeholder="00.00" style="text-align:right">   
                    </td>
                    <td class="text-center">
                       {{ $list['gross_weight'] ?? '' }}  {{ $list['weight_type_code'] ?? '' }} 
                    </td>
                    <td class="text-center">
                       {{ $list['product_price'] ?? '' }}
                    </td>
                    <td class="text-center" >
                         {{ $list['tax_per'] ?? '' }}%<br>{{ convertDecimelPoint($list['tax_flat'] ?? '') }}
                    </td>
                    <td class="text-center">{{ convertDecimelPoint($list['amount'] ?? ($list['amount'] ?? '')) }}</td>
                    <td class="text-center">
                        <a style="line-height:24px;" data-url="{{ route('cart-products-remove') }}" data-type='product' data-id="{{ $list['product_id']  }}"  class="btn btn-danger deleteDataCustom" href="#" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="left" title="Delete">
                            <i class="bi bi-trash text-white"></i>
                        </a>
                    </td>

                    @php $product_price += preg_replace("/[^0-9.]/", "", $list['amount']); @endphp
                </tr>
                @php $i++; @endphp
                @endforeach
                @else
                <tr>
                    <td colspan="9">No Data Found</td>
                </tr>
                @endif

            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $('#checkout').html('Total Amount  in cart {!! $product_price !!} ')
    });
</script>
