<div class="container-fluid pt-5">
        <div class="text-center mb-4">
            <h2 class="section-title px-5"><span class="px-2">Trandy Products</span></h2>
        </div>
        <div class="row px-xl-5 pb-3">
        @foreach($trandyproducts as $key => $tranproducts)

        <div class="col-lg-3 col-md-6 col-sm-12 pb-1">
                <div class="card product-item border-0 mb-4">
                    <div class="card-header product-img position-relative overflow-hidden bg-transparent p-0">
                        <img class="img-fluid w-100" src="{{ asset('/storage/'.$tranproducts->thumbnail_img) }}" alt="">
                    </div>
                             @php
                                    $prignalprice=$tranproducts->unit_price;
                                    $descount=$tranproducts->discount;
                                    $price=$prignalprice-$descount;
                             @endphp
                    <div class="card-body border-left border-right text-center p-0 pt-4 pb-3">
                         <p class="product-brand"> {{ $tranproducts->category->name }} </p>
                            <h5 class="product-name">
                            <a href="{{ route('viewproduct',[$tranproducts->id]) }}">
                                  {{ $tranproducts->name }} 
                               </a>
                            </h5>
                        <div class="mt-1"><span class="selling-price">Rs:</span>   <span class="selling-price">{{ number_format($price,2) }}</span></div>
                       <div class="mt-1"><span class="original-price">{{ number_format($tranproducts->unit_price,2) }}</span></div>
                     
                    </div>
                    @php
    $choices = [];
    if($tranproducts->choice_options){
        $rawChoices = json_decode($tranproducts->choice_options, true);
        foreach($rawChoices as $choice){
            $choices[] = [
                'attribute_id' => $choice['attribute_id'],
                'attribute_name' => \App\Models\Attribute::find($choice['attribute_id'])->name ?? '',
                'values' => $choice['values']
            ];
        }
    }

   
@endphp

                    <div class="card-footer d-flex justify-content-between bg-light">
                        <a href="{{ route('viewproduct',[$tranproducts->id]) }}" class="btn btn-sm text-dark p-0"><i class="fas fa-eye text-primary mr-1"></i>View Detail</a>
                        <a href="javascript:void(0);"
               class="btn btn-sm text-dark p-0"
               onclick="show_addtocart_modal(this)"
               data-id="{{ $tranproducts->id }}"
               data-name="{{ $tranproducts->name }}"
               data-images="{{ $tranproducts->photos }}"
               data-unitprice="{{ $tranproducts->unit_price }}"
               data-discount="{{ $tranproducts->discount }}"
               data-unit="{{ $tranproducts->unit }}"
               data-choice='@json($choices)'
               data-colors='@json(json_decode($tranproducts->colors, true))'
               data-stocks='@json($tranproducts->stocks)'
               >
               <i class="fas fa-shopping-cart text-primary me-1"></i> Add To Cart
            </a>
           <!-- data-colors='@json($tranproducts->colors ?? [])' -->

                       <!-- <a href="javascript:void(0);" onclick="show_chat_modal()" class="btn btn-sm text-dark p-0"><i class="fas fa-shopping-cart text-primary mr-1"></i>Add To Cart</a>-->
                    </div>
                    <!--{{ route('addtocart',[$tranproducts->id]) }} -->
                </div>
            </div>

        @endforeach

        
           
        </div>
    </div>

    



@section('modal')
@include('frontend.modal.addtocartmodal')
@endsection


@section('script')
<script>
 const STORAGE_URL = "{{ asset('storage') }}/";
</script>
<script>
    const COLORS = @json(\App\Models\Color::select('name','code')->get());
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
@endsection

   