|
1 | 1 | @extends('themes.xylo.layouts.master') |
2 | 2 |
|
3 | 3 | @section('content') |
4 | | - <div class="container"> |
5 | | - <h2>Your Wishlist</h2> |
6 | | - |
7 | | - @if($products->isEmpty()) |
8 | | - <p>You have no items in your wishlist.</p> |
9 | | - @else |
10 | | - <div class="row"> |
11 | | - @foreach($products as $product) |
12 | | - <div class="col-md-3"> |
13 | | - <div class="card mb-4"> |
14 | | - <img src="{{ $product->thumbnail->url ?? '/images/default.png' }}" class="card-img-top" alt="{{ $product->translation->name ?? 'Product' }}"> |
15 | | - <div class="card-body"> |
16 | | - <h5 class="card-title">{{ $product->translation->name ?? 'Unnamed Product' }}</h5> |
17 | | - <p class="card-text">Reviews: {{ $product->reviews_count }}</p> |
18 | | - {{-- Add more product info here --}} |
| 4 | +@php $currency = activeCurrency(); @endphp |
| 5 | + |
| 6 | +<div class="container py-5"> |
| 7 | + <h1 class="sec-heading mb-5">My Wishlist</h1> |
| 8 | + |
| 9 | + @if($products->isEmpty()) |
| 10 | + <div class="alert alert-info">Your wishlist is empty.</div> |
| 11 | + @else |
| 12 | + <div class="row"> |
| 13 | + @foreach ($products as $product) |
| 14 | + <div class="col-md-3 mb-4"> |
| 15 | + <div class="product-card"> |
| 16 | + |
| 17 | + <div class="product-img position-relative"> |
| 18 | + <img src="{{ Storage::url(optional($product->thumbnail)->image_url ?? 'default.jpg') }}" |
| 19 | + alt="{{ $product->translation->name }}" style="object-fit: contain; width: 100%; height: 250px;"> |
| 20 | + |
| 21 | + <!-- Same wishlist heart like homepage --> |
| 22 | + <button class="wishlist-btn border-0 bg-transparent" |
| 23 | + data-product-id="{{ $product->id }}"> |
| 24 | + <i class="fa-solid fa-heart text-danger"></i> |
| 25 | + </button> |
| 26 | + </div> |
| 27 | + |
| 28 | + <div class="product-info mt-4"> |
| 29 | + <div class="top-info"> |
| 30 | + <div class="reviews"> |
| 31 | + <i class="fa-solid fa-star"></i> ({{ $product->reviews_count }} Reviews) |
| 32 | + </div> |
| 33 | + </div> |
| 34 | + |
| 35 | + <div class="bottom-info"> |
| 36 | + <div class="left"> |
| 37 | + <h3> |
| 38 | + <a href="{{ route('product.show', $product->slug) }}" class="product-title"> |
| 39 | + {{ $product->translation->name }} |
| 40 | + </a> |
| 41 | + </h3> |
| 42 | + |
| 43 | + <p class="price"> |
| 44 | + <span class="original {{ optional($product->primaryVariant)->converted_discount_price ? 'has-discount' : '' }}"> |
| 45 | + {{ $currency->symbol }}{{ optional($product->primaryVariant)->converted_price ?? 'N/A' }} |
| 46 | + </span> |
| 47 | + |
| 48 | + @if(optional($product->primaryVariant)->converted_discount_price) |
| 49 | + <span class="discount"> |
| 50 | + {{ $currency->symbol }}{{ $product->primaryVariant->converted_discount_price }} |
| 51 | + </span> |
| 52 | + @endif |
| 53 | + </p> |
| 54 | + </div> |
| 55 | + |
| 56 | + <!-- Same Add to Cart button --> |
| 57 | + <button class="cart-btn" onclick="addToCart({{ $product->id }})"> |
| 58 | + <i class="fa fa-shopping-bag"></i> |
| 59 | + </button> |
19 | 60 | </div> |
20 | 61 | </div> |
| 62 | + |
21 | 63 | </div> |
22 | | - @endforeach |
23 | | - </div> |
24 | | - @endif |
25 | | - </div> |
| 64 | + </div> |
| 65 | + @endforeach |
| 66 | + </div> |
| 67 | + @endif |
| 68 | +</div> |
| 69 | +@endsection |
| 70 | + |
| 71 | +@section('js') |
| 72 | +<script> |
| 73 | +$(document).on('click', '.wishlist-btn', function () { |
| 74 | + let button = $(this); |
| 75 | + let productId = button.data('product-id'); |
| 76 | +
|
| 77 | + $.post('{{ route("customer.wishlist.toggle") }}', { |
| 78 | + _token: '{{ csrf_token() }}', |
| 79 | + product_id: productId |
| 80 | + }, function(res) { |
| 81 | + if (res.status === 'removed') { |
| 82 | + button.closest('.col-md-3').fadeOut(); |
| 83 | + } |
| 84 | + }); |
| 85 | +}); |
| 86 | +</script> |
26 | 87 | @endsection |
0 commit comments