I am connecting my website to Shopify using the API and Webhooks. When I create a product on my website, I want it to be created on Shopify. That works. But Shopify sends me back a Webhook telling me that a product has been created: So it creates the same product back on my website… I also want product to be created the other way.
I can’t use Shopify product id to check if the product already exists on my website because I haven’t received it yet.
I feel like I might find a way to make it work, but I am not sure it will be the cleanest way. I am wondering what is the best solution for this scenario.
EDIT: (Adding current ideas)
- The first idea that I have (I think it is a very bad way of doing it, but @Nathan told me to give talk about my ideas :) ), is to unsubscribe from product_create webhook and re-subscribe when I have the ID.
- The second one, is the make a request based on the product sku. That may work, but it doesn't seems like the strongest solution.
Any chance there is a way to just ask Shopify not to send me back the webhook when I create the product?
EDIT 2: Other idea:
- Delay the execution of the webhook on my website with a sleep(5) so I have time to same the shopify ID before dealing with the webhook.