How can I check the colors that are already selected in the product?
For my query I am using getProduct followed by
productByHandle
My query:
Reuslt:
Color Admin:
How can I check the colors that are already selected in the product?
For my query I am using getProduct followed by
productByHandle
My query:
Reuslt:
Color Admin:
Hi @ViniciusGG
I am from Mageplaza - Shopify solution expert.
With your current query, you aren’t fetching the selected colors for each variant yet because:
You need to update your query by adding selectedOptions inside node, like this:
variants(first: 5) {
edges {
node {
id
title
price {
amount
currencyCode
}
availableForSale
selectedOptions {
name
value
}
}
}
}
Specifically, you need to:
Example of the response after adding selectedOptions:
{
"data": {
"productByHandle": {
"variants": {
"edges": [
{
"node": {
"id": "...",
"title": "Red Shirt",
"selectedOptions": [
{ "name": "Color", "value": "Red" },
{ "name": "Size", "value": "M" }
]
}
},
{
"node": {
"id": "...",
"title": "Blue Shirt",
"selectedOptions": [
{ "name": "Color", "value": "Blue" },
{ "name": "Size", "value": "L" }
]
}
}
]
}
}
}
}
=> This way, you can easily tell that the product has the colors Red and Blue.
Please let me know if it works as expected!
Best regards!