Skip to content

Commit 37cfa2f

Browse files
authored
Merge pull request #161 from velstorelabs/feature/admin-validation-v2
Add wishlist listing page with product view button and dynamic wishli…
2 parents 0f01480 + 40adc90 commit 37cfa2f

File tree

3 files changed

+82
-21
lines changed

3 files changed

+82
-21
lines changed

app/Http/Controllers/Store/WishlistController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function index()
1919
->orderBy('wishlists.created_at', 'desc')
2020
->get();
2121

22-
return view('wishlist.index', compact('products'));
22+
return view('themes.xylo.wishlist', compact('products'));
2323
}
2424

2525
public function toggle(Request $request)

resources/views/themes/xylo/layouts/header.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</form>
7171

7272
<!-- Wishlist Icon -->
73-
<a href="{{ auth()->check() ? route('customer.wishlist.index') : route('customer.login') }}" class="text-dark homepage-icon">
73+
<a href="{{ auth('customer')->check() ? route('customer.wishlist.index') : route('customer.login') }}" class="text-dark homepage-icon">
7474
<i class="fa-regular fa-heart"></i>
7575
</a>
7676

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,87 @@
11
@extends('themes.xylo.layouts.master')
22

33
@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>
1960
</div>
2061
</div>
62+
2163
</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>
2687
@endsection

0 commit comments

Comments
 (0)