alexsanford1
alexsanford1

Reputation: 3727

How to get Shopify Shop ID inside of product/update Webhook?

I'm developing a Shopify app that sets up a "product/create" Webhook through the Shopify API.

While the Webhook is sending a POST to the correct address with no problem, it seems that it is not supplying the ID of the shop that the product has been created for. This is a problem because I need to store metadata for the shop and its products. I need to ensure that the link exists in my database between the shop and its products.

Is there a way to either:

Thanks in advance!

Upvotes: 4

Views: 4621

Answers (2)

Arjun Vachhani
Arjun Vachhani

Reputation: 1958

When Shopify sends request to your webhook url. it will also send some extra details in HTTP header.

You can find X-Shopify-Shop-Domain header which will contain domain name of store. From domain name you can extract name of store.

it also contains X-Shopify-Hmac-SHA256 to verify aunthenticity of request.

Upvotes: 9

David Lazar
David Lazar

Reputation: 11427

If you are handed a product in the products/create webhook, you are handed the domain of the incoming call. Once you authenticate the incoming domain, you can clearly query your persistance layer for the shop's token to match the domain. With that, establish the API connection you need, and voila... you can get the Shop and all it's details.

Typically you do NOT need the shop ID for anything, since the myshopify_domain is your key in almost all cases of any work done between Shopify and your App.

Upvotes: 3

Related Questions