checkout
نظرة عامة
استرجع سلة المتسوق مع عناصر السطر والأسعار ومعلومات القسيمة وبيانات الدفع الوصفية. استخدمه لعرض ملخص مباشر أثناء خطوات الدفع.
- النوع: GraphQL Query
- Endpoint: https://appssubdomain.com
- المصادقة:
Authorization: Bearer <TOKEN>(يعتمد على الجلسة/الحساب)
Query
query getcheckout {
cart {
data {
_id
coupon
kind
couponApplied
couponDiscount
items {
productId
_id
variantId
productData {
price
slug
title
}
variantData {
compareAtPrice
price
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
deviceId
sessionId
status
totalQuantity
totalPrice
totalCompareAtPrice
totalSavings
isFastOrder
createdAt
updatedAt
url
encryptionKey
}
success
message
}
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://appssubdomain.com\
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{ "query": "query getcheckout { cart { data { _id totalPrice totalQuantity items { _id quantity totalPrice } } success message } }" }
EOF
const res = await fetch('https://appssubdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `query getcheckout { cart { data { _id totalPrice totalQuantity } success message } }`,
}),
});
const json = await res.json();
ملاحظات
- استبدل
<TOKEN>ببيانات اعتماد الجلسة/الحساب المناسبة. - وسّع الحقول المحددة (مثل productData للعنصر) بناءً على ما تعرضه في صفحة الدفع.
- استخدم
success/messageللتعامل مع السلال الفارغة أو منتهية الصلاحية بشكل سلس.