Skip to content

On a schedule

Plan reorders from Shopify sales in a sheet

Each morning your Reorders sheet shows every product's stock, daily sales rate, days left and how many to reorder.

Runs
On a schedule
Apps
Google Sheets, Shopify
AI
Not needed
Access
Shopify read_inventory, read_orders; Sheets write

Send this to your assistant

Create a ClickRuntime automation: every morning, work out each Shopify variant's sales per day over the last 30 days, write stock, days left and a suggested reorder quantity to my Reorders sheet, and email me the ones under 14 days.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A pet supplies shop orders from four suppliers with lead times from one to five weeks. The buyer guesses quantities from memory and the Shopify stock page, and the result is either an empty shelf or a stockroom full of the wrong thing.

A reorder sheet that recalculates every morning from real sales gives the buyer a starting point grounded in demand. They adjust for promotions and seasons, but no longer start from a guess.

What you get out of it

  • Order quantities based on demand

    Suggested quantities come from how fast each item actually sells. Cash goes into stock that will move, not into items that sit.

  • Everything on one sheet

    Stock, sales rate, days left and suggested order sit side by side for every variant. Sort by days left and the priorities are obvious.

  • Room for your own judgement

    The sheet is yours to annotate with supplier, lead time or notes about promotions. The automation only rewrites its own columns.

  • An email for the urgent ones

    Items with under two weeks of stock are emailed each morning. You know what needs ordering today without opening the sheet.

How it works

What happens, step by step

  1. Every morning, ClickRuntime reads stock levels for each product variant in your Shopify store.

  2. It counts how many of each were sold in the last 30 days to get a daily sales rate.

  3. It works out the days of stock left and a suggested reorder quantity for each one.

  4. The figures are written to your Reorders sheet, replacing yesterday's.

  5. Items with less than 14 days left are emailed to you as a short list.

Before it runs live

  • Connect your Google Sheets account and pick the spreadsheets it may use
  • Connect Shopify

What you get

RunsOn a schedule
Plan reorders from Shopify sales in a sheettoday, 9:00Succeeded
Email · 3 products to reorderGrain-free kibble 2kg: 6 days left, reorder about 120

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Google Sheets and Shopify steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
predict_stockouts_and_log_reorder_needs.pyexample
from datetime import date, timedelta
from collections import Counter
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, notify

STORE = "your-store.myshopify.com"

def gql(query, variables=None):
    resp = http.post(f"https://{STORE}/admin/api/2025-07/graphql.json", json={"query": query, "variables": variables or {}},
                     headers={"X-Shopify-Access-Token": credentials.connection("shopify", "store")})
    return resp.raise_for_status() or resp.json()["data"]

SHEET_ID, COVER_DAYS = "your-spreadsheet-id", 45

@on_trigger
def run(event):
    orders = gql("""query($q: String!) { orders(first: 250, query: $q) { nodes { lineItems(first: 50) { nodes { quantity variant { id } } } } } }""",
                 {"q": f"created_at:>={date.today() - timedelta(days=30)}"})["orders"]["nodes"]
    sold = Counter()
    for o in orders:
        sold.update({li["variant"]["id"]: li["quantity"] for li in o["lineItems"]["nodes"] if li["variant"]})
    rows, urgent = [], []
    for v in gql("{ productVariants(first: 250) { nodes { id sku displayName inventoryQuantity } } }")["productVariants"]["nodes"]:
        rate = sold[v["id"]] / 30
        days = round(v["inventoryQuantity"] / rate) if rate else ""
        reorder = max(0, round(rate * COVER_DAYS - v["inventoryQuantity"]))
        rows.append([v["sku"], v["displayName"], v["inventoryQuantity"], round(rate, 2), days, reorder])
        if days != "" and days < 14:
            urgent.append(f"{v['displayName']}: {days} days left, reorder about {reorder}")
    sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    sheets.spreadsheets().values().update(spreadsheetId=SHEET_ID, range="Reorders!A2", valueInputOption="USER_ENTERED", body={"values": rows}).execute()
    if urgent:
        notify.email_me(f"{len(urgent)} products to reorder", "\n".join(urgent))
    return {"variants": len(rows), "urgent": len(urgent)}

FAQ

Common questions

How is the suggested quantity calculated?
Daily sales rate multiplied by the number of days you want to cover, such as 45, minus current stock. You can set the cover period per supplier if lead times differ.
Does it place orders with suppliers?
No. It suggests quantities in the sheet. You or your buyer decide and place the order.
What about seasonal products?
The rate uses the last 30 days, so it follows recent demand. Before a busy season, you can raise the cover period to build stock ahead of time.
What permissions does it need?
Shopify read_inventory, read_orders; Sheets write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (on a schedule). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Plan reorders from Shopify sales in a sheet” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.