Event

This task is triggered anytime an event in Shopify happens. When task is created, Shopify webhook is created as well. The payload of the webhook will be available for your use inside task's code.

Here is an example of how you can add a tag to order anytime new order is created.

{% assign order = payload %}

{% capture mutation %}
  mutation tagsAdd($id: ID!, $tags: [String!]!) {
    tagsAdd(id: $id, tags: $tags) {
      node {
        id
      }
      userErrors {
        field
        message
      }
    }
  }
{% endcapture %}

{% json variables %}
  {
    "id": "{{ order.admin_graphql_api_id }}",
    "tags": "datajet-tag"
  }
{% endjson %}

{% assign result = mutation | graphql: variables %}

Object payload is preloaded anytime task is triggered that is why it is available for us at very first line of the code. For readability we assign payload to order variable.

If you are not sure what is inside webhook payload you can reference this site provided by Shopify:

Complete list of events available in the app:

checkouts/delete checkouts/create checkouts/update collections/delete collections/create collections/update customers/create customers/delete customers/disable customers/enable customers/update customer_groups/create customer_groups/delete customer_groups/update draft_orders/create draft_orders/delete draft_orders/update fulfillments/create fulfillments/update inventory_items/create inventory_items/delete inventory_items/update inventory_levels/connect inventory_levels/disconnect inventory_levels/update locations/create locations/delete locations/update orders/cancelled orders/create orders/delete orders/edited orders/fulfilled orders/paid orders/partially_fulfilled orders/updated order_transactions/create products/create products/delete products/update refunds/create shop/update tender_transactions/create themes/create themes/delete themes/publish themes/update

Last updated