I'm trying to retrieve products from my Shopify store with this code, a near copy/paste of the examples page for the Javascript Buy SDK:
$(function() {
var shopClient = ShopifyBuy.buildClient({
accessToken: '4b4e3d4bba63039f2d51db94c2e79a46',
domain: 'squatch-air-clutches-test.myshopify.com',
appId: '6'
});
shopClient.fetchQueryProducts({
collection_id: 1397227547
}).then(function(products) {
$('.test').append(JSON.stringify(products));
});
shopClient.fetchProduct('46656520219').then(function(product) {
$('.test').append(JSON.stringify(product));
});
});
Here's a fiddle.
The buildClient
command seems to complete successfully, however I get a console error with the next two commands: Error: Not Found
. I assume this refers to the product not able to be found, but I am sure both the product and the collection ids are correct. And I am also sure that I have read access
enabled for "products, variants, and collections" for my private app. Would there be any other reason I am getting this error, and if so, what's a solution?
Got it. The App ID was incorrect. I needed to go to /admin/settings/storefront_access_tokens
and grab the correct ID for my sales channel. I'm disappointed that it was so difficult to find though - the documentation on this seems convoluted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With