I created a metafield "count" inside products. Now I want to increment the value of "count" when some item is sold. I'm new to shopify. So, your help will be highly appriciated.
Thanks
I created a metafield "count" inside products. Now I want to increment the value of "count" when some item is sold. I'm new to shopify. So, your help will be highly appriciated.
Thanks
Thanks for the reply Carted, unfortunately removing the attribute or using null as a value results in the response.
Script tags don't go through the liquid pipeline because it's just your server serving up the assets. If you need the permanent domain you could turn your JS file into a rendered template and feed in a locally cached shop object with all the data you need
# controller.rb # /scripts/:shop_id respond_to :js def show @shop = Shop.find(params[:shop_id]) end # scripts/show.js.erb var shop = "<%= @shop.permanent_domain %>" var newPage = "http://myserver.com?shop=" + shop function openNewPage() { window.open(newPage); }
Have you tried not including variant_title? That information will be pulled from Shopify
There's no plans for anything at the moment. Yes it's been requested a bunch and there's ways to get access to it but the API is pretty gross and undocumented.
Keep your eyes on the API announcements forum, that's where we will make the announcement if/when it becomes available.
The options are maintained by the Product, so making a change to the option will make a change to that for all your product variants.
options: [ { id: 123, name: "Size", position: 1, product_id: 321 }, { id: 908, name: "Color", position: 2, product_id: 809 }, { id: , name: "Style", position: 3, product_id: 92368952 } ],
You'll need to write an application that integrates with order creation webhooks. When that product is sold you update the value.
I just tried
{"order": {"line_items": [ {"quantity": 2,"variant_id": 314451299 } ] } }
And I get the error
{"errors":{"order":["Line items is invalid"],"line_items":["can't have missing variant details, missing variant_id"]}}
We are trying to get a sold count from the product endpoint so we can sort products in our system by best selling like users can already do through custom collections. This attribute currently does not appear to exist on the product endpoint.
Is there another way to get this data? If not, can you add it?
Thanks,
Jason
Is there a way to include a Snippet (not Asset) with an app?
Looks like Snippets are reusable across themes, whereas Assets are theme-specific.
We don't track this kind of information. You can use webhooks to keep track of product sales and then re-order your top selling collection based on that collected information.
Shopify doesn't track this kind of information.
I'm just doing a simple "orders/create" webhook. I'm doing the verification of the webhook by looking at the headers based on this doc: http://docs.shopify.com/api/tutorials/using-webhooks#verify-webhook
Headers I see:
{"Accept":"*\/*","Accept-Encoding":"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","Connection":"close","Host":"example.com","User-Agent":"Ruby","X-Newrelic-Id":"VQQUVFdSDwMF","X-Newrelic-Transaction":"PxRRU1RTAAFSUlZQAQZSA10DFB8EBw8RVT8=","X-Shopify-Order-Id":"123456678","X-Shopify-Shop-Domain":"example.myshopify.com","X-Shopify-Test":"false","X-Shopify-Topic":"orders\/create"}
As you can see, the X-Shopify-Hmac-SHA256 header is not being passed. Any ideas?
Thanks for the reply Chris. I am confused because you already provide this sort option, so I would assume you would provide the data you use to perform this sort through the API. It may not be sold count, but I assume there is some attribute you use to perform this sort. Can you tell me what product attribute you use to sort products by "best selling" in custom collections?
If you are unwilling to surface this data, can you surface a call that allows one to get a list of products for a custom collection sorted by "best selling"?
Thanks,
Jason
Did you create the webhook yourself using the API or are you testing from within the admin in the settings -> notifications?
If you created it using the API, you'll get the right header information, otherwise you won't, since it is just to test the endpoints out and not a real, secure webhook.
Not sure I agree with that from a functional standpoint but at least I have an answer. Learn something new every day. Thanks much.
It makes total sense. Your App has a private:public keypair you use to validate the HMAC and your connection to the shop. The Shopify Admin notifications section has no clue about the existence of your private:public keys, so how can it possibly generate an HMAC for you?
Like you say, lesson learned every day... when you generate a webhook with your App, Shopify will know your keys and hence can generate the HMAC.
Oh I totally agree with that. I'm just saying that it would be nice to have a method for verifying all webhooks. This way I can have a non technical user manage which webhooks are enabled while still having them be more secure.
According to http://docs.shopify.com/api/tutorials/using-webhooks Webhooks will retry when failed for 2 days.
If a product is updated on Monday which triggers the "updated product" alert and it fails for 24 hours, finally being accepted on Tuesday; will the product info included in the alert contain the state of the product from Monday (possibly stale), or will it contain the latest product version known to Shopify?
Thanks
The content is always pulled from the database when sending a webhook, so you don't have to worry about the data being stale.
Not everyone needs a full app to create webhooks and even to just verify that your own signature code is working, it would be great to not have to create a full application, register the webhook and validate it. We've experienced the same problem you have had internally and are looking into a way to provide message verification.
It's easy to say you *shouldn't* be using these webhooks, but people might need a one off, or it just sticks around because you get it working and it's good enough. I don't know exactly when we'll have this out, but keep your eyes on the API Announcements forum where we'll announce this change when it comes out.
For now you can just use a private app to create your webhooks, which contains the shared_secret which you can use to validate the content we are sending to you.