Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VSI-MART
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dhanaraj
VSI-MART
Commits
ef301ef2
Commit
ef301ef2
authored
Jun 04, 2026
by
Venkatshiva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whishlist funtion and page design
parent
a85b51cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
43 deletions
+158
-43
main.js
public/main.js
+74
-0
wishlist.blade.php
resources/views/wishlist.blade.php
+80
-43
web.php
routes/web.php
+4
-0
No files found.
public/main.js
View file @
ef301ef2
...
@@ -2,6 +2,13 @@
...
@@ -2,6 +2,13 @@
let
cart
=
JSON
.
parse
(
localStorage
.
getItem
(
'vsimart_cart'
))
||
[];
let
cart
=
JSON
.
parse
(
localStorage
.
getItem
(
'vsimart_cart'
))
||
[];
let
appliedCoupon
=
false
;
let
appliedCoupon
=
false
;
// Session ID tracking for guest wishlist
let
guestSessionId
=
localStorage
.
getItem
(
'vsimart_session_id'
);
if
(
!
guestSessionId
)
{
guestSessionId
=
'sess_'
+
Math
.
random
().
toString
(
36
).
substring
(
2
,
15
)
+
Date
.
now
().
toString
(
36
);
localStorage
.
setItem
(
'vsimart_session_id'
,
guestSessionId
);
}
function
updateCartHeader
()
{
function
updateCartHeader
()
{
let
count
=
cart
.
length
;
// number of distinct products selected
let
count
=
cart
.
length
;
// number of distinct products selected
$
(
'.cart-count-badge'
).
text
(
cart
.
reduce
((
t
,
i
)
=>
t
+
i
.
quantity
,
0
));
// badge shows total qty
$
(
'.cart-count-badge'
).
text
(
cart
.
reduce
((
t
,
i
)
=>
t
+
i
.
quantity
,
0
));
// badge shows total qty
...
@@ -653,6 +660,73 @@ $(document).ready(function() {
...
@@ -653,6 +660,73 @@ $(document).ready(function() {
}
}
}
}
// Wishlist click handler
$
(
document
).
on
(
'click'
,
'.btn-wishlist'
,
function
(
e
)
{
e
.
preventDefault
();
const
btn
=
$
(
this
);
let
card
=
btn
.
closest
(
'.product-card, .col-lg-4, .col-lg-3, .col-md-6'
);
let
prodCard
=
btn
.
closest
(
'[id^="prod-card-"]'
);
let
productId
=
null
;
if
(
prodCard
.
length
&&
prodCard
.
attr
(
'id'
))
{
productId
=
prodCard
.
attr
(
'id'
).
replace
(
'prod-card-'
,
''
);
}
else
{
let
addToCartBtn
=
card
.
find
(
'.btn-add-to-cart-dynamic'
);
if
(
addToCartBtn
.
length
)
{
productId
=
addToCartBtn
.
data
(
'id'
);
}
}
if
(
!
productId
)
{
productId
=
btn
.
data
(
'id'
);
}
if
(
!
productId
)
{
console
.
error
(
'Could not find product ID for wishlist'
);
return
;
}
$
.
ajax
({
url
:
'/api/wishlist'
,
method
:
'POST'
,
headers
:
{
'X-Session-ID'
:
guestSessionId
,
'X-CSRF-TOKEN'
:
$
(
'meta[name="csrf-token"]'
).
attr
(
'content'
)
||
''
},
data
:
{
product_id
:
productId
},
success
:
function
(
res
)
{
if
(
res
.
success
)
{
btn
.
find
(
'i'
).
removeClass
(
'fa-regular bi-heart'
).
addClass
(
'fa-solid bi-heart-fill text-danger'
);
if
(
$
(
'#wishlist-toast'
).
length
===
0
)
{
let
toast
=
$
(
`
<div id="wishlist-toast" style="
position: fixed; bottom: 28px; right: 28px; z-index: 9999;
background: #ef4444; color: #fff; padding: 14px 22px;
border-radius: 12px; font-family: 'Plus Jakarta Sans', sans-serif;
font-size: 0.93rem; font-weight: 600; box-shadow: 0 8px 28px rgba(0,0,0,0.25);
display: flex; align-items: center; gap: 10px;
">
<span style="font-size:1.3rem;">❤️</span>
<span id="wishlist-toast-msg">Added to Wishlist!</span>
</div>
`
);
$
(
'body'
).
append
(
toast
);
setTimeout
(()
=>
{
toast
.
fadeOut
(
400
,
()
=>
toast
.
remove
());
},
2500
);
}
else
{
$
(
'#wishlist-toast-msg'
).
text
(
res
.
message
);
$
(
'#wishlist-toast'
).
fadeIn
();
setTimeout
(()
=>
{
$
(
'#wishlist-toast'
).
fadeOut
();
},
2500
);
}
}
},
error
:
function
(
xhr
)
{
console
.
error
(
xhr
);
alert
(
'Failed to update wishlist. Please try again.'
);
}
});
});
// Call initially on load
// Call initially on load
checkAuthStatus
();
checkAuthStatus
();
});
});
resources/views/wishlist.blade.php
View file @
ef301ef2
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
My Wishlist - VSI Mart
</title>
<title>
My Wishlist - VSI Mart
</title>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<!-- Google Fonts -->
<!-- Google Fonts -->
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
...
@@ -100,43 +101,7 @@
...
@@ -100,43 +101,7 @@
<!-- Wishlist Items Grid -->
<!-- Wishlist Items Grid -->
<div
class=
"row g-4"
id=
"wishlist-grid"
>
<div
class=
"row g-4"
id=
"wishlist-grid"
>
<!-- Wishlist Card 1 -->
<!-- Dynamically populated via AJAX -->
<div
class=
"col-lg-3 col-md-6 wishlist-item-card"
data-id=
"p1"
>
<div
class=
"card product-card border rounded-3 overflow-hidden shadow-sm h-100"
>
<div
class=
"position-relative"
>
<span
class=
"badge-bestseller"
>
Best Seller
</span>
<button
class=
"btn btn-link text-danger position-absolute top-0 end-0 p-2 fs-5 remove-wishlist-btn"
title=
"Remove Item"
style=
"z-index: 10;"
><i
class=
"bi bi-trash-fill"
></i></button>
<img
src=
"https://images.unsplash.com/photo-1618221195710-dd6b41faaea6?w=500&auto=format&fit=crop&q=80"
class=
"card-img-top object-fit-cover"
alt=
"Decorative Shell Wall Frame"
height=
"220"
>
</div>
<div
class=
"card-body d-flex flex-column p-3"
>
<h5
class=
"product-title fw-bold mb-1"
style=
"font-size: 0.95rem; color: #000000;"
>
Decorative Shell Wall Frame
</h5>
<div
class=
"d-flex align-items-center mb-2"
>
<span
class=
"product-price fw-bold text-dark fs-5"
>
₹850
</span>
<span
class=
"product-price-strike text-muted small ms-2"
>
₹935
</span>
</div>
<button
class=
"btn btn-custom-primary w-100 mt-auto rounded-pill text-white btn-add-to-cart-dynamic"
data-id=
"p1"
data-name=
"Decorative Shell Wall Frame"
data-price=
"850"
data-img=
"https://images.unsplash.com/photo-1618221195710-dd6b41faaea6?w=500&auto=format&fit=crop&q=80"
>
Add to cart
</button>
</div>
</div>
</div>
<!-- Wishlist Card 2 -->
<div
class=
"col-lg-3 col-md-6 wishlist-item-card"
data-id=
"p2"
>
<div
class=
"card product-card border rounded-3 overflow-hidden shadow-sm h-100"
>
<div
class=
"position-relative"
>
<span
class=
"badge-bestseller"
>
Best Seller
</span>
<button
class=
"btn btn-link text-danger position-absolute top-0 end-0 p-2 fs-5 remove-wishlist-btn"
title=
"Remove Item"
style=
"z-index: 10;"
><i
class=
"bi bi-trash-fill"
></i></button>
<img
src=
"https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=500&auto=format&fit=crop&q=80"
class=
"card-img-top object-fit-cover"
alt=
"Seashell Wind Chime"
height=
"220"
>
</div>
<div
class=
"card-body d-flex flex-column p-3"
>
<h5
class=
"product-title fw-bold mb-1"
style=
"font-size: 0.95rem; color: #000000;"
>
Seashell Wind Chime
</h5>
<div
class=
"d-flex align-items-center mb-2"
>
<span
class=
"product-price fw-bold text-dark fs-5"
>
₹450
</span>
<span
class=
"product-price-strike text-muted small ms-2"
>
₹535
</span>
</div>
<button
class=
"btn btn-custom-primary w-100 mt-auto rounded-pill text-white btn-add-to-cart-dynamic"
data-id=
"p2"
data-name=
"Seashell Wind Chime"
data-price=
"450"
data-img=
"https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=500&auto=format&fit=crop&q=80"
>
Add to cart
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Empty Wishlist Message -->
<!-- Empty Wishlist Message -->
...
@@ -205,16 +170,88 @@
...
@@ -205,16 +170,88 @@
<script
src=
"{{ asset('main.js') }}"
></script>
<script
src=
"{{ asset('main.js') }}"
></script>
<script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
// Remove item action animation
function
loadWishlist
()
{
$
(
'.remove-wishlist-btn'
).
click
(
function
()
{
const
sessId
=
localStorage
.
getItem
(
'vsimart_session_id'
)
||
''
;
let
card
=
$
(
this
).
closest
(
'.wishlist-item-card'
);
$
.
ajax
({
card
.
fadeOut
(
400
,
function
()
{
url
:
'/api/wishlist'
,
card
.
remove
();
method
:
'GET'
,
if
(
$
(
'.wishlist-item-card'
).
length
===
0
)
{
headers
:
{
'X-Session-ID'
:
sessId
},
success
:
function
(
res
)
{
if
(
res
.
success
&&
res
.
data
.
length
>
0
)
{
let
html
=
''
;
res
.
data
.
forEach
(
item
=>
{
let
p
=
item
.
product
;
if
(
!
p
)
return
;
let
imgUrl
=
p
.
primary_image
?
p
.
primary_image
.
image_url
:
'https://images.unsplash.com/photo-1618221195710-dd6b41faaea6?w=500&auto=format&fit=crop&q=80'
;
html
+=
`
<div class="col-lg-3 col-md-6 wishlist-item-card" data-id="
${
p
.
id
}
">
<div class="card product-card border rounded-3 overflow-hidden shadow-sm h-100">
<div class="position-relative">
${
p
.
is_bestseller
?
'<span class="badge-bestseller">Best Seller</span>'
:
''
}
<button class="btn btn-link text-danger position-absolute top-0 end-0 p-2 fs-5 remove-wishlist-btn" data-id="
${
p
.
id
}
" title="Remove Item" style="z-index: 10;"><i class="bi bi-trash-fill"></i></button>
<img src="
${
imgUrl
}
" class="card-img-top object-fit-cover" alt="
${
p
.
name
}
" height="220">
</div>
<div class="card-body d-flex flex-column p-3">
<h5 class="product-title fw-bold mb-1" style="font-size: 0.95rem; color: #000000; height: 38px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">
${
p
.
name
}
</h5>
<div class="d-flex align-items-center mb-2">
<span class="product-price fw-bold text-dark fs-5">₹
${
Math
.
round
(
p
.
price
)}
</span>
</div>
<button class="btn btn-custom-primary w-100 mt-auto rounded-pill text-white btn-add-to-cart-dynamic"
data-id="
${
p
.
id
}
"
data-name="
${
p
.
name
}
"
data-price="
${
Math
.
round
(
p
.
price
)}
"
data-img="
${
imgUrl
}
">Add to cart</button>
</div>
</div>
</div>
`
;
});
$
(
'#wishlist-grid'
).
html
(
html
).
removeClass
(
'd-none'
);
$
(
'#empty-wishlist-msg'
).
addClass
(
'd-none'
);
}
else
{
$
(
'#wishlist-grid'
).
addClass
(
'd-none'
).
html
(
''
);
$
(
'#empty-wishlist-msg'
).
removeClass
(
'd-none'
);
}
},
error
:
function
()
{
$
(
'#wishlist-grid'
).
addClass
(
'd-none'
);
$
(
'#wishlist-grid'
).
addClass
(
'd-none'
);
$
(
'#empty-wishlist-msg'
).
removeClass
(
'd-none'
);
$
(
'#empty-wishlist-msg'
).
removeClass
(
'd-none'
);
}
}
});
});
}
// Initial load
loadWishlist
();
// Remove item click handler
$
(
document
).
on
(
'click'
,
'.remove-wishlist-btn'
,
function
()
{
let
productId
=
$
(
this
).
data
(
'id'
);
let
card
=
$
(
this
).
closest
(
'.wishlist-item-card'
);
const
sessId
=
localStorage
.
getItem
(
'vsimart_session_id'
)
||
''
;
$
.
ajax
({
url
:
'/api/wishlist/'
+
productId
,
method
:
'DELETE'
,
headers
:
{
'X-Session-ID'
:
sessId
,
'X-CSRF-TOKEN'
:
$
(
'meta[name="csrf-token"]'
).
attr
(
'content'
)
},
success
:
function
(
res
)
{
if
(
res
.
success
)
{
card
.
fadeOut
(
400
,
function
()
{
card
.
remove
();
if
(
$
(
'.wishlist-item-card'
).
length
===
0
)
{
$
(
'#wishlist-grid'
).
addClass
(
'd-none'
);
$
(
'#empty-wishlist-msg'
).
removeClass
(
'd-none'
);
}
});
}
}
});
});
});
});
});
</script>
</script>
...
...
routes/web.php
View file @
ef301ef2
...
@@ -40,6 +40,10 @@ Route::get('/gallery', function () {
...
@@ -40,6 +40,10 @@ Route::get('/gallery', function () {
Route
::
get
(
'/catalog'
,
[
FrontendController
::
class
,
'ourCollection'
]);
Route
::
get
(
'/catalog'
,
[
FrontendController
::
class
,
'ourCollection'
]);
Route
::
get
(
'/wishlist'
,
function
()
{
return
view
(
'wishlist'
);
});
Route
::
get
(
'/dashboard'
,
function
()
{
Route
::
get
(
'/dashboard'
,
function
()
{
return
view
(
'dashboard'
);
return
view
(
'dashboard'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment