json
Last updated
{% json config %}
{
"enabled": true,
"max_items": 50,
"api_version": "2024-01"
}
{% endjson %}
{% if config.enabled %}
{% log "Config loaded, max items: " | append: config.max_items %}
{% endif %}{% json order_payload %}
{
"order_id": {{ order.id }},
"customer": {
"email": "{{ customer.email }}",
"name": "{{ customer.first_name }} {{ customer.last_name }}"
},
"total": {{ order.total_price }},
"currency": "{{ shop.currency }}"
}
{% endjson %}
{% log "Payload created for order: " | append: order_payload.order_id %}{% json request_body %}
{
"event": "purchase",
"properties": {
"product_ids": {{ line_items | map: "product_id" | json }},
"total_value": {{ order.total_price }},
"currency": "{{ order.currency }}"
},
"user_id": "{{ customer.id }}"
}
{% endjson %}
{% json headers %}
{
"Content-Type": "application/json",
"Authorization": "Bearer {{ API_KEY }}"
}
{% endjson %}
{% http url: "https://api.example.com/events", method: "POST", headers: headers, body: request_body as response %}{% json products_array %}
[
{% for item in order.line_items %}
{
"sku": "{{ item.sku }}",
"quantity": {{ item.quantity }},
"price": {{ item.price }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
{% endjson %}
{% log "Products count: " | append: products_array.size %}{% json webhook_payload %}
{
"type": "order.created",
"timestamp": "{{ 'now' | date: '%Y-%m-%dT%H:%M:%SZ' }}",
"data": {
"order": {
"id": {{ order.id }},
"name": "{{ order.name }}",
"line_items": {{ order.line_items | json }}
},
"customer": {
"id": {{ customer.id }},
"email": "{{ customer.email }}"
}
},
"metadata": {
"source": "datajet",
"shop": "{{ shop.domain }}"
}
}
{% endjson %}
{% assign customer_email = webhook_payload.data.customer.email %}{% capture query %}
mutation updateProduct($input: ProductInput!) {
productUpdate(input: $input) {
product { id title }
userErrors { field message }
}
}
{% endcapture %}
{% json variables %}
{
"input": {
"id": "gid://shopify/Product/{{ product_id }}",
"title": "{{ new_title }}",
"tags": {{ new_tags | json }}
}
}
{% endjson %}
{% graphql query: query, variables: variables as result %}{% comment %} Inside a function, use 'response' to set return value {% endcomment %}
{% json response %}
{
"success": true,
"data": {
"processed": {{ items_processed }},
"errors": []
}
}
{% endjson %}
{% return response %}{% json notification %}
{
"channel": "email",
"recipient": "{{ customer.email }}",
"template": "{% if order.total_price > 100 %}vip_order{% else %}standard_order{% endif %}",
"priority": {% if order.fulfillment_status == "unfulfilled" %}1{% else %}5{% endif %}
}
{% endjson %}{% comment %} This will throw an error - missing quotes around value {% endcomment %}
{% json invalid %}
{
"key": invalid_value
}
{% endjson %}