Book Image

Shopify Application Development

By : Michael Larkin
Book Image

Shopify Application Development

By: Michael Larkin

Overview of this book

Table of Contents (12 chapters)

Exploring webhooks


Shopify allows applications to subscribe to a series of notifications called webhooks (http://docs.shopify.com/api/webhook) around common events such as order placement, product updates, and customer signup. Real-world events are mapped to topics that can be subscribed to via the API or by manual setup in the Shopify admin panel. The webhook notification mirrors the format of the API, which makes the implementation code reusable. When an event occurs, Shopify automatically sends the notification to all subscribers.

Orders

Order webhooks allow apps to respond in a near real-time fashion when an order is placed or updated in the Shopify store. The following two events are the most commonly subscribed topics that deal with the creation and payment of an Order:

  • orders/create

  • orders/paid

Products

Product webhooks can be handy for apps that handle inventory, product feeds, or back office integrations. The following three events are of interest when dealing with Products:

  • products/create

  • products/update

  • products/delete

Shop/Application

It will be helpful to automatically reflect any updates to a shop's name, URL, and so on in your app. Likewise, it's polite to suspend/cancel a user's account if they uninstall the app from their store. The following two events allow us to do that:

  • shop/update

  • app/uninstall

Webhooks are sent asynchronously after the event occurs. This makes them suitable for near real-time actions and allows an application to process information in smaller chunks, which can reduce the load and improve performance.

Tip

I also recommend using the API to retrieve information as a backup in case the webhook system gets bogged down or a notification is missed.

For public applications, the webhook for uninstalling the application should be subscribed to so that you can automatically suspend the client's account when they remove your app from their Shopify store.