博客
🛍️ WooCommerce 集成已登陆 Gato GraphQL!
作者:Leonardo Losoviz ·
WooCommerce 扩展现已在 Gato GraphQL 中可用! 🎉

这款全新扩展允许我们从 WooCommerce 获取数据,包括商品、订单、客户、优惠券等。
以下是从您的 WooCommerce 商店获取数据的 Query 示例。
商品(全部)
此 Query 获取所有商品的基本信息:
query FetchAllProducts {
woocommerceProducts {
__typename
id
name
slug
url
urlPath
sku
...on WooCommercePriceableProductOrProductVariation {
price
priceFormatted
regularPrice
regularPriceFormatted
salePrice
salePriceFormatted
onSale
}
status
type
featured
totalSales
averageRating
ratingCount
image {
id
src
altText
title
caption
}
categories {
id
name
slug
}
tags {
id
name
slug
}
brands {
id
name
slug
}
}
woocommerceProductsCount
}商品(按类型)
简单商品
此 Query 获取所有简单商品:
query FetchSimpleProducts {
woocommerceSimpleProducts {
__typename
id
name
slug
url
urlPath
sku
description
shortDescription
price
priceFormatted
regularPrice
regularPriceFormatted
salePrice
salePriceFormatted
onSale
status
type
featured
totalSales
averageRating
ratingCount
image {
id
src
altText
title
caption
}
categories {
id
name
slug
}
tags {
id
name
slug
}
brands {
id
name
slug
}
# Stock management fields
manageStock
stockQuantity
stockStatus
backorders
backordersAllowed
backordered
soldIndividually
lowStockThreshold
# Shipping fields
isVirtual
weight
length
width
height
dimensions
shippingClassID
shippingClass {
id
name
slug
description
count
}
# Downloadable fields
isDownloadable
downloadLimit
downloadExpiry
downloads
downloadsCount
# Tax fields
taxStatus
taxClass
# Cross-sell fields
crossSellIDs
crossSells {
id
name
slug
sku
}
}
woocommerceSimpleProductsCount
}外部商品
此 Query 获取所有外部商品:
query FetchExternalProducts {
woocommerceExternalProducts {
__typename
id
name
slug
url
urlPath
sku
description
shortDescription
price
priceFormatted
regularPrice
regularPriceFormatted
salePrice
salePriceFormatted
onSale
status
type
featured
totalSales
averageRating
ratingCount
image {
id
src
altText
title
caption
}
categories {
id
name
slug
}
tags {
id
name
slug
}
brands {
id
name
slug
}
# External product specific fields
externalURL
buttonText
# Tax fields
taxStatus
taxClass
}
woocommerceExternalProductsCount
}组合商品
此 Query 获取所有组合商品:
query FetchGroupProducts {
woocommerceGroupProducts {
__typename
id
name
slug
url
urlPath
sku
description
shortDescription
status
type
featured
totalSales
averageRating
ratingCount
image {
id
src
altText
title
caption
}
categories {
id
name
slug
}
tags {
id
name
slug
}
brands {
id
name
slug
}
# Group product specific fields
hasChildren
childrenCount
minPrice
maxPrice
minPriceFormatted
maxPriceFormatted
children {
id
name
slug
sku
}
}
woocommerceGroupProductsCount
}可变商品
此 Query 获取所有可变商品:
query FetchVariableProducts {
woocommerceVariableProducts {
__typename
id
name
slug
url
urlPath
sku
description
shortDescription
status
type
featured
totalSales
averageRating
ratingCount
image {
id
src
altText
title
caption
}
categories {
id
name
slug
}
tags {
id
name
slug
}
brands {
id
name
slug
}
# Variable product specific fields
hasVariations
variationsCount
minPrice
maxPrice
minRegularPrice
maxRegularPrice
minSalePrice
maxSalePrice
priceRange
variations {
id
name
slug
sku
}
defaultAttributes {
taxonomy
termSlug
termObject {
id
name
slug
}
}
# Cross-sell fields
crossSellIDs
crossSells {
id
name
slug
sku
}
# Tax fields
taxStatus
taxClass
}
woocommerceVariableProductsCount
}客户
此 Query 获取所有客户:
query FetchCustomers {
woocommerceCustomers {
__typename
id
username
email
firstName
lastName
displayName
description
createdDate
createdDateStr
formattedCreatedDateStr: createdDateStr(format: "d/m/Y H:i:s")
modifiedDate
modifiedDateStr
formattedModifiedDateStr: modifiedDateStr(format: "d/m/Y H:i:s")
role
billing
shipping
isPayingCustomer
avatarURL
totalSpent
totalSpentFormatted
orderCount
lastOrderID
lastOrder {
id
orderNumber
status
total
date
}
orders {
id
orderNumber
status
total
date
}
ordersCount
}
woocommerceCustomersCount
}订单
此 Query 获取所有订单:
query FetchOrders {
woocommerceOrders {
__typename
id
orderNumber
orderKey
date
modifiedDate
dateStr
formattedDateStr: dateStr(format: "d/m/Y H:i:s")
modifiedDateStr
formattedModifiedStr: modifiedDateStr(format: "d/m/Y H:i:s")
status
isPaid
currency
total
totalFormatted
subtotal
subtotalFormatted
totalTax
totalTaxFormatted
totalShipping
totalShippingFormatted
totalDiscount
totalDiscountFormatted
totalDiscountTax
totalDiscountTaxFormatted
shippingTotal
shippingTotalFormatted
shippingTax
shippingTaxFormatted
cartTax
cartTaxFormatted
totalFee
totalFeeFormatted
customerID
customer {
id
username
email
firstName
lastName
displayName
}
customerNote
billingAddress
shippingAddress
hasCompletedStatus: hasStatus(status: "completed")
hasPendingStatus: hasStatus(status: "pending")
hasProcessingStatus: hasStatus(status: "processing")
hasOnHoldStatus: hasStatus(status: "on-hold")
hasCancelledStatus: hasStatus(status: "cancelled")
hasRefundedStatus: hasStatus(status: "refunded")
hasFailedStatus: hasStatus(status: "failed")
hasAnyCompletedOrProcessingStatus: hasAnyStatus(statuses: ["completed", "processing"])
hasAnyPendingOrOnHoldStatus: hasAnyStatus(statuses: ["pending", "on-hold"])
paymentMethod
paymentMethodTitle
transactionID
datePaid
datePaidStr
formattedDatePaidStr: datePaidStr(format: "d/m/Y H:i:s")
dateCompleted
dateCompletedStr
formattedDateCompletedStr: dateCompletedStr(format: "d/m/Y H:i:s")
cartHash
newOrderEmailSent
orderCurrency
orderVersion
pricesIncludeTax
discountTotal
discountTax
refunded
remainingRefundAmount
itemCount
items {
id
name
quantity
subtotal
subtotalFormatted
total
totalFormatted
totalTax
totalTaxFormatted
productID
variationID
reducedStockNumber
product {
id
name
slug
sku
}
variation {
id
name
slug
sku
}
}
refunds {
id
amount
amountFormatted
reason
status
}
downloadPermissionsGranted
needsPayment
needsProcessing
isDownloadPermitted
hasDownloadableItem
}
woocommerceOrdersCount
}退款
此 Query 获取所有退款:
query FetchRefunds {
woocommerceRefunds {
__typename
id
orderID
order {
id
orderNumber
status
}
amount
amountFormatted
reason
refundedBy {
id
name
email
}
isPaymentRefundedViaAPI
refundType
date
modifiedDate
dateStr
formattedDateStr: dateStr(format: "d/m/Y H:i:s")
modifiedDateStr
formattedModifiedDateStr: modifiedDateStr(format: "d/m/Y H:i:s")
status
}
woocommerceRefundsCount
}评价
此 Query 获取所有商品评价:
query FetchProductReviews {
woocommerceReviews {
__typename
id
content
author
authorEmail
rating
verified
approved
date
dateStr
productID
product {
id
name
}
}
woocommerceReviewsCount
}优惠券
此 Query 获取所有优惠券:
query FetchCoupons {
woocommerceCoupons {
__typename
id
code
amount
amountFormatted
dateExpires
dateExpiresStr
formattedDateExpiresStr: dateExpiresStr(format: "d/m/Y H:i:s")
discountType
description
date
modifiedDate
dateStr
formattedDateStr: dateStr(format: "d/m/Y H:i:s")
modifiedDateStr
formattedModifiedDateStr: modifiedDateStr(format: "d/m/Y H:i:s")
usageCount
individualUse
productIDs
products {
id
name
slug
}
productsCount
excludedProductIDs
excludedProducts {
id
name
slug
}
excludedProductsCount
usageLimit
usageLimitPerUser
limitUsageToXItems
freeShipping
productCategoryIDs
productCategories {
id
name
slug
}
productCategoriesCount
excludedProductCategoryIDs
excludedProductCategories {
id
name
slug
}
excludedProductCategoriesCount
productBrandIDs
productBrands {
id
name
slug
}
productBrandsCount
excludedProductBrandIDs
excludedProductBrands {
id
name
slug
}
excludedProductBrandsCount
excludeSaleItems
minimumAmount
minimumAmountFormatted
maximumAmount
maximumAmountFormatted
emailRestrictions
usedByCustomerIDs
usedByCustomers {
id
username
email
firstName
lastName
displayName
}
usedByCustomersCount
}
woocommerceCouponsCount
}更多内容
您可以在以下资源中找到更多示例: