Skip to main content

Wishlist

Add to Wishlist

POST /ajax/wishlist/add
{
"productId": "69651f5119d6eec96d853b31"
}

Remove from Wishlist

POST /ajax/wishlist/remove
{
"productId": "69651f5119d6eec96d853b31"
}

Clear Wishlist

POST /ajax/wishlist/clear

JavaScript Example

async function addToWishlist(productId) {
const res = await fetch('/ajax/wishlist/add', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ productId })
});
return res.json();
}

async function removeFromWishlist(productId) {
const res = await fetch('/ajax/wishlist/remove', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ productId })
});
return res.json();
}

SDK Alternative

Coming Soon

Wishlist SDK module قيد التطوير. حالياً استخدم الـ AJAX المباشر.

بعد التوفر، هتقدر تستخدم:

await qumra.wishlist.add('PRODUCT_ID');
await qumra.wishlist.remove('PRODUCT_ID');
await qumra.wishlist.clear();
const items = qumra.wishlist.get();

وتسمع للأحداث:

qumra.on('wishlist:added', (payload) => {
heartIcon.classList.add('active');
});