$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-revenue-by-location-reportRead-only: breaks down revenue by fulfillment location for multi-warehouse P&L and location performance.
| 1 | ## Purpose |
| 2 | Attributes order revenue to the fulfillment location that shipped the order. Produces a revenue breakdown by warehouse or fulfillment center, useful for multi-location P&L, location staffing decisions, and understanding where demand is being fulfilled from. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders` |
| 6 | - API scopes: `read_orders` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | days_back | integer | no | 30 | Lookback window | |
| 14 | | format | string | no | human | Output format: `human` or `json` | |
| 15 | |
| 16 | ## Safety |
| 17 | |
| 18 | > ℹ️ Read-only skill — no mutations are executed. Safe to run at any time. |
| 19 | |
| 20 | ## Workflow Steps |
| 21 | |
| 22 | 1. **OPERATION:** `locations` — query |
| 23 | **Inputs:** `first: 50`, active only |
| 24 | **Expected output:** Location IDs and names for enrichment |
| 25 | |
| 26 | 2. **OPERATION:** `orders` — query |
| 27 | **Inputs:** `query: "fulfillment_status:shipped created_at:>='<NOW - days_back days>'"`, `first: 250`, select `fulfillments { assignedLocation }`, `totalPriceSet`, pagination cursor |
| 28 | **Expected output:** Fulfilled orders with location attribution |
| 29 | |
| 30 | 3. **OPERATION:** `fulfillmentOrders` — query (for open orders attribution) |
| 31 | **Inputs:** Per location, `status: CLOSED`, `first: 250` |
| 32 | **Expected output:** Closed fulfillment orders for revenue attribution |
| 33 | |
| 34 | 4. Aggregate revenue by location; orders without location data attributed to "Unknown" |
| 35 | |
| 36 | ## GraphQL Operations |
| 37 | |
| 38 | ```graphql |
| 39 | # locations:query — validated against api_version 2025-01 |
| 40 | query LocationsList { |
| 41 | locations(first: 50, includeInactive: false) { |
| 42 | edges { |
| 43 | node { |
| 44 | id |
| 45 | name |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | ```graphql |
| 53 | # orders:query — validated against api_version 2025-01 |
| 54 | query RevenueByLocation($query: String!, $after: String) { |
| 55 | orders(first: 250, after: $after, query: $query) { |
| 56 | edges { |
| 57 | node { |
| 58 | id |
| 59 | name |
| 60 | createdAt |
| 61 | totalPriceSet { |
| 62 | shopMoney { |
| 63 | amount |
| 64 | currencyCode |
| 65 | } |
| 66 | } |
| 67 | fulfillments { |
| 68 | assignedLocation { |
| 69 | location { |
| 70 | id |
| 71 | name |
| 72 | } |
| 73 | } |
| 74 | status |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | pageInfo { |
| 79 | hasNextPage |
| 80 | endCursor |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | ``` |
| 85 | |
| 86 | ```graphql |
| 87 | # fulfillmentOrders:query — validated against api_version 2025-01 |
| 88 | query ClosedFulfillmentOrders($locationId: ID!, $after: String) { |
| 89 | fulfillmentOrders( |
| 90 | assignedLocationId: $locationId |
| 91 | first: 250 |
| 92 | after: $after |
| 93 | query: "status:closed" |
| 94 | ) { |
| 95 | edges { |
| 96 | node { |
| 97 | id |
| 98 | order { |
| 99 | id |
| 100 | name |
| 101 | totalPriceSet { |
| 102 | shopMoney { |
| 103 | amount |
| 104 | currencyCode |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | pageInfo { |
| 111 | hasNextPage |
| 112 | endCursor |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | ``` |
| 117 | |
| 118 | ## Session Tracking |
| 119 | |
| 120 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 121 | |
| 122 | **On start**, emit: |
| 123 | ``` |
| 124 | ╔══════════════════════════════════════════════╗ |
| 125 | ║ SKILL: Revenue by Location Report ║ |
| 126 | ║ Store: <store domain> ║ |
| 127 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 128 | ╚══════════════════════════════════════════════╝ |
| 129 | ``` |
| 130 | |
| 131 | **After each step**, emit: |
| 132 | ``` |
| 133 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 134 | → Params: <brief summary of key inputs> |
| 135 | → Result: <count or outcome> |
| 136 | ``` |
| 137 | |
| 138 | **On completion**, emit: |
| 139 | |
| 140 | For `format: human` (default): |
| 141 | ``` |
| 142 | ══════════════════════════════════════════════ |
| 143 | REVENUE BY LOCATION (<days_back> days) |
| 144 | Total revenue: $<amount> |
| 145 | Orders included: <n> |
| 146 | |
| 147 | Location Orders Revenue Share |
| 148 | ───────────────────────────────────────────────── |
| 149 | Warehouse A <n> $<n> <pct>% |
| 150 | Warehouse B <n> $<n> <pct>% |
| 151 | Output: revenue_by_location_<date>.csv |
| 152 | ══════════════════════════════════════════════ |
| 153 | ``` |
| 154 | |
| 155 | For `format: json`, emit: |
| 156 | ```json |
| 157 | { |
| 158 | "skill": "revenue-by-location-report", |
| 159 | "store": "<domain>", |
| 160 | "period_days": 30, |
| 161 | "total_revenue": 0, |
| 162 | "currency": "USD", |
| 163 | "by_location": [], |
| 164 | "output_file": "revenue_by_location_<date>.csv" |
| 165 | } |
| 166 | ``` |
| 167 | |
| 168 | ## Output Format |
| 169 | CSV file `revenue_by_location_<YYYY-MM-DD>.csv` with columns: |
| 170 | `location_id`, `location_name`, `order_count`, `total_revenue`, `currency`, `share_pct` |
| 171 | |
| 172 | ## Error Handling |
| 173 | | Error | Cause | Recovery | |
| 174 | |-------|-------|----------| |
| 175 | | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retr |