Closed atikju closed 3 years ago
@atikju Any detail what error you are getting?
@tareqtms
Fatal error: Uncaught PHPShopify\Exception\ApiException: message - Variable $handle is used by anonymous query but not declared, locations - line - 2, column - 30, path - query, collectionByHandle, handle, extensions - code - variableNotDefined, variableName - handle in phpclassic/php-shopify/lib/ShopifyResource.php:554 Stack trace: #0 phpclassic/php-shopify/lib/GraphQL.php(49): PHPShopify\ShopifyResource->processResponse(Array) #1 xcollections/index.php(66): PHPShopify\GraphQL->post('query {\n colle...', 'https://f78bf26...', NULL, Array) #2 {main} thrown in phpclassic/php-shopify/lib/ShopifyResource.php on line 554
@atikju Can you show the rest of the code, where you are making the final call?
@tareqtms
I'm just doing this:
$data = $shopify->GraphQL->post($graphQL, null, null, $variables);
echo "<pre>";
var_dump($data["data"]);
echo "</pre>";
Try this
$graphQL = <<<Query
query(\$handle: String!) {
collectionByHandle(handle: \$handle) {
products(first: 30) {
edges {
node {
images(first: 1) {
edges {
node {
src
}
}
}
handle
variants(first: 10) {
edges {
node {
compareAtPrice
price
}
}
}
}
}
}
}
}
Query;
@tareqtms
This one works mate! Thanks very much!
What am I missing here? See my codes below: