انتقل إلى المحتوى الرئيسي

Get Cart

Returns the current cart contents.

GET /ajax/cart

JavaScript Example

async function getCart() {
const res = await fetch('/ajax/cart');
return res.json();
}

SDK Alternative

// جلب السلة من السيرفر (يحدّث الحالة المحلية)
const cart = await qumra.cart.fetch();

// أو قراءة الحالة المحلية مباشرة (بدون طلب للسيرفر)
const cart = qumra.cart.get();

console.log(cart.totalPrice); // 15000
console.log(cart.itemCount); // 3
console.log(cart.items[0].productData.title); // "قميص أزرق"

// هل المنتج في السلة؟
qumra.cart.has('69651f5119d6eec96d853b31'); // true

// كمية المنتج
qumra.cart.getQuantity('69651f5119d6eec96d853b31'); // 2