> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcemedium.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# rpt_shopify_order_fulfillment

> Fulfillment status of each Shopify order, with its first shipment and delivery times.

Where each Shopify order's fulfillment stands, and when it first shipped and arrived.

* **Grain:** One row per (`sm_store_id`, `order_id`): every valid order that was not cancelled.
* **Date field:** `order_created_at`.
* **Filters to start with:** `order_fulfillment_status` (`fulfilled`, `partial`, `unfulfilled`).
* **Joins:** Join [`obt_orders`](https://docs.sourcemedium.com/docs/data-activation/data-tables/sm_transformed_v2/obt_orders) on (`sm_store_id`, `order_id`) for revenue, customer and marketing fields.

## Which stores and orders have rows

Rows exist only for Shopify stores whose orders come entirely through SourceMedium's own Shopify connection. Other stores have no rows, so an empty result means the store is not covered, not that every order shipped. Fulfilled orders stay in the table, so a covered store with nothing waiting still has rows.

Orders Shopify marks as restocked or as needing no fulfillment are left out, and so are orders archived in Shopify before they were fully fulfilled. Orders archived after they shipped stay, so shipping times include them.

## Reading the columns

* `order_fulfillment_status` covers the order's lines that need fulfillment: `fulfilled` when all of them shipped, `partial` when some did, `unfulfilled` when none did.
* `fulfillable_quantity` is the units still waiting to ship. It is null when Shopify reports no quantity for a waiting line, so read null as unknown, not zero.
* `first_fulfilled_at`, `first_in_transit_at` and `first_delivered_at` all describe the order's first successful fulfillment. For an order shipped in several parts, they describe the first part. Transit and delivery times appear only when Shopify reports them.
* `orders_synced_at` says how current the store's orders are: statuses reflect Shopify updates up to that time.

## Example: orders waiting to ship

The same rule [`rpt_fulfillment_backlog_daily`](https://docs.sourcemedium.com/docs/data-activation/data-tables/sm_transformed_v2/rpt_fulfillment_backlog_daily) counts each day: unfulfilled or partly fulfilled, with units left to ship or an unknown number.

```sql theme={null}
SELECT
  order_name,
  order_created_at,
  order_fulfillment_status,
  fulfillable_quantity,
  order_product_titles_csv
FROM `your_project.sm_transformed_v2.rpt_shopify_order_fulfillment`
WHERE sm_store_id = 'your-sm_store_id'
  AND order_fulfillment_status IN ('unfulfilled', 'partial')
  AND (fulfillable_quantity > 0 OR fulfillable_quantity IS NULL)
ORDER BY order_created_at
```

## Example: days to ship by week

```sql theme={null}
SELECT
  DATE_TRUNC(DATE(order_created_at), WEEK) AS order_week,
  COUNT(*) AS shipped_orders,
  APPROX_QUANTILES(TIMESTAMP_DIFF(first_fulfilled_at, order_created_at, HOUR), 100)[OFFSET(50)] / 24 AS median_days_to_ship
FROM `your_project.sm_transformed_v2.rpt_shopify_order_fulfillment`
WHERE sm_store_id = 'your-sm_store_id'
  AND first_fulfilled_at IS NOT NULL
  AND DATE(order_created_at) >= DATE_SUB(CURRENT_DATE(), INTERVAL 12 WEEK)
GROUP BY order_week
ORDER BY order_week
```

## Columns

| Column | Type | Description |
| - | - | - |
| `sm_store_id` | STRING | SourceMedium's unique store identifier. For Shopify stores, derived from the myshopify.com domain; for other platforms (Amazon, TikTok Shop, Walmart.com), uses platform-specific identifiers. |
| `first_delivered_at` | TIMESTAMP | When that first fulfillment was delivered, if Shopify reports it. |
| `first_fulfilled_at` | TIMESTAMP | When the order's first successful fulfillment was created. |
| `first_in_transit_at` | TIMESTAMP | When that first fulfillment went in transit, if Shopify reports it. |
| `fulfillable_quantity` | INT64 | Units still waiting to ship on the order's open lines. Null when Shopify reports no quantity for one of them, so read null as unknown. |
| `order_created_at` | TIMESTAMP | When the order was created. |
| `order_fulfillment_status` | STRING | fulfilled, partial or unfulfilled, across the order's lines that need fulfillment. |
| `order_id` | STRING | Shopify order identifier. |
| `order_name` | STRING | Order reference the customer sees, such as #1001. |
| `order_product_titles_csv` | STRING | Product titles on the order. |
| `orders_synced_at` | TIMESTAMP | When the store's Shopify orders were last synced. Statuses reflect Shopify updates up to this time. |
| `source_system` | STRING | Commerce platform the order came from. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.