<!-- Built by scripts/build-agent-docs.mjs from site/agents-src/shopify.md: edit that file. -->
# Page Lemon Shopify: guide for AI assistants

> For people: https://pagelemon.com/docs/shopify explains this feature in plain words. This page is for AI assistants.

A site can be connected to the person's own Shopify store. Page Lemon then keeps a read-only copy of its products and collections in Lists (`products`, `collections`, `product_collections`), refreshed on a schedule, and a Buy button sends the buyer to Shopify's own checkout. Shopify stays the system of record for prices, stock, payment, tax, shipping and orders, and Page Lemon never changes your products, orders, customers or stock in Shopify.

Use this when the person asks to build a shop, lookbook or app "from my Shopify store". Not for selling things Shopify doesn't sell (use `/agents/payments`), and not for moving off Shopify.

## Plans and limits

Every plan can connect a store. How often the store syncs and how many items the account holds depend on the plan (the pricing page has them; never type a number). Synced rows count as items: past the allowance the newest are kept, and the connection's `notice` is `over_limit`. Say so, and point at the pricing page; do not retry.

## Ask the person

1. Which store (`your-store.myshopify.com`).
2. What the site shows: every product, one collection, a lookbook, a "new in" strip; and the look (match their theme or new).
3. Which way to connect: a **Storefront token** (shop sites; the Headless channel) or **their own app** (a shop site and a team portal: orders, customers and stock, read-only).

## What the person needs ready

A Shopify admin login. For the token: install the **Headless** channel, **Create storefront**, copy the private access token. For their own app: **Dev Dashboard**, create an app in their own organisation, tick only the read scopes the Dashboard screen shows, install it, copy the client id and secret.

**Never ask for a token, client id or secret in chat, and never accept one pasted there.** Send the person to the Dashboard screen `https://dash.pagelemon.com/sites/<site>/shopify`; the keys are sealed there and no tool, answer or log returns one.

## Set it up

1. Tell the person to open the site's **Shopify** screen and press **Test and connect** (REST: `save_shopify_connection`, account sign-in only; an API key or AI connection can't save keys).
2. Read `site_read` `what=site`: its `shopify` part shows `status`, `shop_name`, `product_count`, `last_sync_at`, `notice`, `last_error` (our own codes: `shopify_refused_token`, `shop_not_found`, `shopify_request_refused`, `shopify_busy`, `shopify_unreachable`, `list_name_taken`). No `shopify` part means not connected.
3. Once `last_sync_at` is set, `list_read` `what=lists` shows `products`, `collections` and `product_collections`; read them with `list_read` `what=items`.
4. Sync now is the Dashboard's button (REST `sync_shopify`).

## Put it on the page

Pages and Views read the synced lists like any list: `data-pl-list="products"` with `data-pl-field` for `title`, `description`, `price`, `compare_at_price`, `currency`, `image_url`, `available`, `handle`, `tags`, `variant_id`. The template **Shelf** is a working shop over them.
A Buy button posts a form to `/__pl/shopify/cart` on the site's own host with `variant` (the product's `variant_id`) and `quantity`; the visitor lands on Shopify's checkout. Page markup fills text, not form values, so copy the `variant_id` into the hidden input with a small script (Shelf's `script.js` does). One page never mixes a Shopify cart with Page Lemon Payments. Prices are Shopify's, in the store's currency; show the currency sign yourself.

## Test

Open the live page, press a Buy button and report whether it reached the Shopify checkout page. Tell the person the result before saying the shop is live.

## Day to day

- Shopify fields are read-only here: adding, editing, deleting, reordering, importing and changing the fields of a synced list is `409 list_synced_readonly`. Tell the person to change it in Shopify.
- The person's own extra columns work: `list_save` with `owner_columns`, then an item's `owner` (a "featured" tick, a badge, notes). They stay across syncs and go with a product Shopify deletes.
- Automations can listen for `shopify.sync.finished` and `shopify.sync.failed`.

## Store team (the read-only portal)

With an own-app connection (`kind: admin`) the sync also mirrors `orders`, `customers` and `inventory` (one row per variant and place; the places are in the rows) into team-only lists. They need the site's team sign-in on; otherwise the connection's `notice` is `needs_team`. Nobody adds, edits or deletes rows. Every row carries `admin_url`, the "Open in Shopify" link to that record in Shopify admin: that is where a change is made. Orders cover a recent window that depends on the plan. Person fields (`email`, `phone`, `ship_to`, `note`, `name`, `city`, `country`) are hidden fields: do not copy them into a content list or a public page.

- **The promise to say, exactly:** Page Lemon never changes your products, orders, customers or stock in Shopify. The person's app needs read scopes only (products, orders, customers, inventory). The one thing written to Shopify is a public Storefront token made once at connect so Buy works (it needs the `unauthenticated_*` scopes the person ticked); it changes nothing in the store.
- **No writes of any kind:** there is no tool, route, button or automation step that fulfils, refunds, cancels, tags, adjusts stock or changes a price or a product, and no ShopifyQL or reports. If the person asks, say so and give the row's `admin_url` or tell them to do it in Shopify.
- **No instant updates:** there are no webhooks. Rows arrive on the plan's schedule, and Sync now brings the next sync forward. Nothing is saved from Shopify's own notifications.
- **No Shopify customer sign-in and no "My orders":** visitors sign in the site's own way. Page Lemon does not read a customer's orders from Shopify for them.
- **Their own lists beside the copy:** the team keeps ordinary team lists (returns, notes, follow-ups) linked by order or customer id.
- **The template:** `store-team` starts a team portal with orders, customers, low stock and a returns list, each row with its Open in Shopify link. See `/agents/templates`.
- **Low-stock alert:** an automation on `item.updated` of `inventory` with the condition `available lt <number>` emails or messages the team; it changes nothing in Shopify.
- Disconnecting, or Shopify refusing the key three times in a row, removes the keys and every copied row. Orders and customers are never in a Page Lemon backup.

## What Page Lemon refuses, and the fix

| Refusal | Step to offer |
|---|---|
| `409 list_synced_readonly` | Change it in Shopify; offer an own column for anything of theirs. |
| `shopify_connection_invalid` (`shopify_refused_token`) | The key is wrong or was rotated: make a new one in Shopify and paste it on the Shopify screen. |
| `shopify_connection_invalid` (`shop_not_found`) | Check the `your-store.myshopify.com` address. |
| `list_name_taken` in `last_error` | A list named `products`, `collections` or `product_collections` already exists and isn't from Shopify: rename it. |
| `notice: over_limit` | The plan's item allowance is full: free up items or choose a bigger plan. |
| Buy button goes to a Page Lemon "not open for buying" page | The connection is missing or is an own-app connection without a Storefront token. |
| Transfer blocked with `shopify` | Disconnect the store first. |

## Links

- People: https://pagelemon.com/docs/shopify
- Lists guide: https://pagelemon.com/agents/lists · Payments (for what Shopify doesn't sell): https://pagelemon.com/agents/payments · All guides: https://pagelemon.com/agents
