Query Plugin DataWooCommerce
WooCommerce
Examples of queries to interact with data from the WooCommerce plugin.
Fetching product data
This query fetches the title and content for a given product:
query GetProduct($productId: ID!) {
product: customPost(by: { id: $productId }, customPostTypes: "product") {
id
title
content
}
}
Updating product data
This query updates the title and content for a given product:
mutation UpdateProduct(
$productId: ID!
$title: String!
$content: String!
) {
updateCustomPost(input: {
id: $productId,
customPostType: "product"
title: $title
contentAs: {
html: $content
}
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
__typename
...on CustomPost {
id
title
content
}
}
}
}
Prev
Next