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

productPrice

نظرة عامة

استخدم resolvePrice لحساب الأسعار المباشرة (مثلاً لأدوات الشراء السريع) دون لمس السلة. قدم المنتج، المتغير/الخيارات الاختيارية، والكمية للحصول على الإجماليات/التوفيرات بالإضافة إلى بيانات المنتج الكاملة.

  • النوع: GraphQL Mutation
  • Endpoint: https://subdomain.com
  • المصادقة: Authorization: Bearer <TOKEN> (إذا كان متجرك يتطلب سياق العميل)

Mutation

mutation ResolvePrice($input: ResolvePriceInput!) {
resolvePrice(input: $input) {
success
message
data {
productId
variantId
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
product {
_id
title
slug
description
app
tags
status
publishedAt
images { _id fileUrl }
collections {
_id
app
title
slug
description
operation
image { _id fileUrl }
}
seo { title description keywords image canonicalUrl }
pricing { compareAtPrice originalPrice price }
variantsCount
dimensions { height width unit }
weight { weight unit }
variants {
_id
product
options {
_id
option { name }
label
type
sortOrder
createdAt
updatedAt
}
images { _id fileUrl }
pricing { originalPrice price compareAtPrice }
quantity
weight { unit weight }
}
options {
_id
product
valuesCount
values { _id label type sortOrder createdAt updatedAt }
name
createdAt
updatedAt
}
}
}
}
}

المتغيرات

{
"input": {
"productId": "<PRODUCT_ID>",
"variantId": "<VARIANT_ID>",
"quantity": 2,
"options": [
{ "name": "size", "value": "M" }
]
}
}

أمثلة

curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation ResolvePrice($input: ResolvePriceInput!) { resolvePrice(input: $input) { success message data { productId totalPrice totalSavings } } }",
"variables": {
"input": {
"productId": "<PRODUCT_ID>",
"variantId": "<VARIANT_ID>",
"quantity": 2
}
}
}
EOF

ملاحظات

  • ممتاز لمعاينة إجماليات الشراء السريع أو بناء حاسبات أسعار مخصصة.
  • احترم التحقق الخاص بالمتجر (المخزون، الحد الأدنى للكمية) واستخدم message لعرض الأخطاء.