[ { "version": 1, "label": "Export Daily Sales to Google Sheet", "trigger_type": [ "order_created" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "1": { "type": "trigger_child_workflow", "settings": { "target_path": "order.line_items", "exported_workflow": { "version": 1, "label": "Line Item subworkflow", "trigger_type": [ "manual" ], "object_type": "line_item", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "4": { "type": "step", "settings": [], "weight": -10, "target_key": null }, "3": { "type": "debug", "settings": { "wait": "0", "custom_wait": "", "action_label": "", "title": "", "body": "{% set day_val = \"sold_\"~'now'|date('Ymd') %}\r\n{% set oldval = line_item.variant.database[day_val] %}\r\n{% set val =line_item.quantity|plus(oldval) %}\r\nNew Qty: {{val}}", "token_object_type": "line_item" }, "weight": 10, "target_key": "line_item" }, "2": { "type": "database_key_value", "settings": { "wait": "0", "custom_wait": "", "resource_type": "variants", "resource_id": "{{ line_item.variant_id }}", "key": "sold_{{'now'|date('Ymd')}}", "value": "{% set day_val = \"sold_\"~'now'|date('Ymd') %}\r\n{% set oldval = line_item.variant.database[day_val] %}\r\n{% set val =line_item.quantity|plus(oldval) %}\r\n{{val}}", "token_object_type": "line_item" }, "weight": 20, "target_key": "line_item" }, "5": { "type": "step", "settings": [], "weight": 29, "target_key": null }, "1": { "type": "google_sheets_v2", "settings": { "wait": "0", "custom_wait": "", "url": "https:\/\/docs.google.com\/spreadsheets\/d\/1mJRFXSoU3NLOOGKs1I4lGRvrjn1uC9hg5tRTYy9HAAA\/edit?usp=sharing", "title": "Untitled spreadsheet", "settings": { "tab": "0", "update_mode": "update", "primary_key": "" }, "cells": [ { "weight": "0", "value": "{{ line_item.title }}" }, { "weight": "1", "value": "{% set day_val = \"sold_\"~'now'|date('Ymd') %}\r\n{% set oldval = line_item.variant.database[day_val] %}\r\n{{oldval}}" } ], "token_object_type": "line_item" }, "weight": 30, "target_key": "line_item" } } } } } } }, "weight": 999, "target_key": "order" } } } } }, "description": "This workflow is a great fit for merchants who would like to track the quantity of each variant sold on a daily basis. The workflow is triggered when an order is created and creates a new row containing the title of the variant and the quantity sold on that particular day. This value is incremented as new orders come in during the day." } ]