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

cartUpdateItem

نظرة عامة

استخدم updateCartItem لتغيير كمية عنصر سطر معين في السلة. يعيد حساب API الإجماليات والقسائم والتوفيرات، ويعيد حالة السلة الجديدة.

  • النوع: GraphQL Mutation
  • Endpoint: https://appssubdomain.com
  • المصادقة: Authorization: Bearer <TOKEN> (الجلسة/الحساب)

Mutation

mutation UpdateCartItem($data: updateCartItemInput!) {
updateCartItem(data: $data) {
data {
_id
app
account {
_id
app
verified
blocked
orderCount
lastSeen
createdAt
updatedAt
}
coupon
kind
couponApplied
couponDiscount
items {
productId
_id
variantId
productData {
title
slug
image { _id fileUrl }
price
}
variantData {
price
compareAtPrice
options {
_id
option { _id name type product }
label
sortOrder
}
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
deviceId
sessionId
status
totalQuantity
totalPrice
totalCompareAtPrice
totalSavings
isFastOrder
createdAt
updatedAt
url
encryptionKey
}
success
message
}
}

المتغيرات

{
"data": {
"itemId": "<CART_ITEM_ID>",
"quantity": 3
}
}

أمثلة

curl -X POST \
https://appssubdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation UpdateCartItem($data: updateCartItemInput!) { updateCartItem(data: $data) { success message data { _id totalPrice totalQuantity } } }",
"variables": {
"data": {
"itemId": "<CART_ITEM_ID>",
"quantity": 3
}
}
}
EOF

ملاحظات

  • عادة ما يفرض الـ backend حدود الحد الأدنى/الأقصى؛ افحص message إذا فشل التحديث.
  • استخدمه جنباً إلى جنب مع removeCartItem و addToCart لبناء تدفقات إدارة السلة الكاملة.