X-Sitter works with a Shopify shop through a **connection** (the access to the shop) and **jobs** (automatic tasks such as importing products, setting the stock or reporting tracking numbers back). You manage both under **Administration › Jobs & connections** (*Administration › Jobs & Verbindungen*) – how that works in general is described in [Jobs & connections](/administration/jobs-and-connections.md). This page covers what is special about Shopify.

## Before you start

- Your user needs the permission **Jobs & connections** in the **Administration** area. As a client, your logistician must also have released the jobs mask for you – see [Jobs & connections](/administration/jobs-and-connections.md).
- Your package has room for the connection and the jobs.
- The shop owner has approved the X-Sitter app in Shopify with all requested permissions. If you connect the shop with your own access data instead, the custom app in the shop needs the same permissions (stock, locations, fulfillments and fulfillment orders).

## How a shop gets connected

| Way | What happens |
|---|---|
| The merchant installs the **X-Sitter app** in Shopify | After the installation the merchant sees "The Shopify app was installed successfully" (*Die Shopify-App wurde erfolgreich installiert*) and logs in to X-Sitter with **Log in now** (*Jetzt anmelden*). With the login the shop is assigned to the merchant's company, a job for fetching the orders (`shopify-get-orders`, comment "Shopify-App") is set up and the open orders are imported right away. |
| The merchant installs an **app that X-Sitter set up for this client** | The shop belongs to the client immediately – nobody has to log in. The page after the installation says "The store is connected to X-Sitter, the open orders are being imported now." (*Der Shop ist mit X-Sitter verbunden, die offenen Bestellungen werden jetzt übernommen.*). Such an app is set up by X-Sitter support on request. |
| You enter the **access data yourself** | Create a connection of the type Shopify with the **Shop URL** (`xxxxxxxxx.myshopify.com`) and the **Admin API access token** (`shpat_…`) of a custom app in the shop. |

A connection created by an installation:

- gets the **shop name** from Shopify as its **Comment** (*Bemerkung*) – if Shopify returns no name, the first part of the myshopify domain. So you can tell several shops apart in the connection dropdowns of the jobs. A comment you entered yourself is kept when the merchant approves the app again.
- is automatically **shared with** (*Teilen mit*) the logistician when the shop belongs to a client. The logistician's jobs (product import, stock) can then choose the shop as their connection without seeing the access data.

X-Sitter always uses the current version of the Shopify Admin API for every shop; there is no version to choose on the connection.

![Screenshot: Connections list with two Shopify shops of clients, each with its comment and the logistician in the column Shared with](/administration/images/shopify-connections-shared.png)

## Stock location in the shop

Shopify keeps stock per location. X-Sitter needs its own location in the shop, and you no longer have to look up a location ID: the job **Bestände setzen** (`shopify-set-products-inventory`) sets the location up on its first run and enters it in the connection. If the connection is set to **Fulfillment service** explicitly, **Fetch orders** (*Bestellungen holen*) does so as well.

### Step by step

1. Open **Administration › Jobs & connections** (*Administration › Jobs & Verbindungen*), click **Connections** (*Verbindungen*) and open the Shopify connection.
2. Leave **Stock location in the shop** (*Lager im Shop*) on **Automatic** (*Automatisch*) – this fits in most cases – and leave **Location ID** (*Location-ID*) empty.
3. Click **Save** (*Speichern*).
4. Create the job **Bestände setzen** (`shopify-set-products-inventory`) for the company that owns the articles (for a client shop: the client), choose the Shopify connection, switch **Active** (*Aktiv*) on and save.
5. Create the job **Fetch orders** (*Bestellungen holen*, `shopify-get-orders`) with the same connection the same way – after an app installation it exists already. How it fetches the orders is described under [Orders through the fulfillment service](#orders-through-the-fulfillment-service).
6. After the first run, the name of the location and the time of the last check appear below **Location ID** on the connection.

![Screenshot: Shopify connection form with Shop URL, the access data fields, the opened selection Stock location in the shop with its three options and the Location ID field with the location name and "checked" time below](/administration/images/shopify-connection-stock-location.png)

### Options

| Option | Meaning |
|---|---|
| **Automatic (logistician: fulfillment service, otherwise location of the shop)** (*Automatisch (Logistiker: Fulfillment-Service, sonst Standort des Shops)*) | Default. A client served by a logistician gets a fulfillment service, a company that ships itself a location of the shop. Orders come through the fulfillment service as soon as **Bestände setzen** has set it up – until then **Fetch orders** fetches all open orders of the shop. |
| **Fulfillment service in the name of the logistician** (*Fulfillment-Service im Namen des Logistikers*) | Shopify creates a location of its own for the service, named after the logistician (renamed when the logistician is renamed). It does not count against the location limit of the Shopify plan, and the merchant does not book stock on it. Orders with articles at this location reach X-Sitter as fulfillment orders. |
| **Location of the shop (location ID or the first active one)** (*Standort des Shops (Location-ID oder der erste aktive)*) | A normal location of the merchant: the one in **Location ID**, otherwise the first active location of the shop. If the shop has none, X-Sitter creates one in the name of the company or reactivates a deactivated one with the same name. |
| **Location ID** (*Location-ID*) | Leave empty – the job enters it. Set it by hand only with "Location of the shop", to use one particular location. |
| **Location-Id (override)** (*Location-Id (Übersteuerung)*) on the job **Bestände setzen** | Only if this one job should send the stock to a different location than the connection. Normally empty. |
| **Location ID (override)** (*Location-ID (Übersteuerung)*) on the job **Fetch orders** | Empty: the job reads the fulfillment requests at the connection's location. Fill it in only if it should read the requests of a different fulfillment service location. |

The jobs check the location again at most every 6 hours.

## Stock sync

The job **Bestände setzen** sends the available stock of the client's articles in the logistician's warehouse to the location in the shop. It repairs typical problems itself:

- An article that is not yet stocked at the location is activated there and sent again.
- If the location was deleted in the shop, the job determines it anew.
- An article that Shopify rejects is left out; all other articles are still sent. You receive a Telegram message with the rejected articles.

Only articles with a Shopify inventory ID take part. The product import sets it – except for bundles and for variants whose stock is not tracked in Shopify; their stock X-Sitter does not overwrite.

## Product import: article names of variants

The product import (`shopify-get-products`) reads all products of the shop with all their variants, page by page. As logistician you can create one product import per client shop in your own company: choose the client's shared shop as **Connection** (*Verbindung*) and the client as **Owner** (*Eigentümer*).

With **Article name for variants** (*Artikelname bei Varianten*) in the job settings you decide how the articles of a product with several variants are named:

| Option | Article name |
|---|---|
| **Product name only** (*Nur Produktname*) | Default, as before: every variant gets the name of the product. |
| **Product name - quantity** (*Produktname - Menge*) | Product name plus the quantity of the variant, e.g. "Ground coffee - 500g". Only variants with a quantity in g, kg, ml or l (also mg and cl) get the addition, the others keep the product name. |
| **Product name - variant** (*Produktname - Variante*) | Product name plus the full variant title, e.g. "T-Shirt - Red / XL". |

Existing articles are renamed with the next run. A product name that already ends with the addition stays as it is, and a product without real variants keeps its name.

![Screenshot: Job settings of the Shopify product import with the opened selection Article name for variants and its three options and the hint below](/administration/images/shopify-job-variant-naming.png)

## Product import: categories and bundles

- **Categories:** A separate nightly run creates categories from the collections of the shop – all collections, also more than 50. Existing categories are renamed at most, none is deleted. If a **Single category** (*Einzelne Kategorie*) is chosen in the job, every imported article gets this category and the collections of this shop are skipped. The import does not assign a collection to the articles themselves.
- **Bundles:** A bundle from Shopify (a product made of several components, e.g. through the Shopify Bundles app) is created by the import as a normal article, but without stock sync. In the order Shopify sends the components as positions of their own, so the components are picked. Which bundle was ordered is not part of the order then – unless you switch on [bundles as a set](#bundles-and-gift-boxes-as-a-set) in the job **Fetch orders**. If the shop sends a set as **one** position with its own SKU instead (some bundle apps), create a [bill of materials](/products/bills-of-materials.md) (*Stückliste*) with this SKU; saving it resolves open orders with the set.

## Orders through the fulfillment service

The job **Fetch orders** (*Bestellungen holen*, `shopify-get-orders`) is the only order import for Shopify. If the connection is set to **Fulfillment service** (the default for clients of a logistician), it works like this:

1. Shopify routes an order to the logistician's location when the articles have stock there.
2. The merchant requests the fulfillment in Shopify – usually automatically, otherwise with **Request fulfillment** on the order.
3. The job takes the order with exactly the lines and quantities of this location and accepts the request. The shop then shows "Vom Lager übernommen, die Bestellung wird vorbereitet." (taken over by the warehouse).
4. After shipping, [Tracking numbers back to Shopify](#tracking-numbers-back-to-shopify) reports the shipment.

If the merchant wants an accepted order back (**Request cancellation**), the job cancels the order and accepts the cancellation as long as the warehouse has not started it. Otherwise you get a Telegram message and stop the shipment yourself. An order the merchant has not requested a fulfillment for after two hours is reported by Telegram as well.

If the connection is set to **Location of the shop**, the job fetches all open orders of the shop – for companies that ship themselves and for shops that have not been switched yet.

### Orders the merchant ships themselves

Sometimes the merchant ships an order themselves, for example from their own store, and marks it as fulfilled in Shopify. The job notices this on both ways: every run checks the orders that were fully fulfilled in Shopify since the last run, archived ones included.

| State of the order in the warehouse | What happens |
|---|---|
| Not started yet (**Offen**, **Wartend**, **Wartet**, **Fehler**) | The order becomes **Erledigt** (completed). Its stock is free again, nothing is reported back to Shopify. You get a Telegram message for your information. |
| Handed to a service provider (**im Versand**, e.g. JTL) | The order becomes **Versendet** (shipped), the provider shipped it. |
| Already in progress (on a picking list, picked, packed …) | The order stays as it is. You get a Telegram message and stop the shipment yourself. |
| Shipped, completed or cancelled | Nothing. |

An order the merchant fulfilled before the job fetched it never reaches the warehouse. Partly fulfilled orders change nothing.

### Switching a shop to the fulfillment service

1. The job **Bestände setzen** exists for the client (see [Stock location in the shop](#stock-location-in-the-shop)).
2. On the connection, set **Stock location in the shop** (*Lager im Shop*) to **Fulfillment service in the name of the logistician**, empty **Location ID** and save. The next run creates the location in the shop, stocks the articles there and sets the stock.
3. The merchant sets the stock of these articles at their previous locations to 0. Otherwise Shopify adds both locations up and keeps routing orders to the old one.
4. The merchant has fulfillment requests sent automatically.

## Fetching orders: release by tag, feedback and greeting cards

The job **Fetch orders** (`shopify-get-orders`) creates the orders of the shop as orders in X-Sitter. Its settings have two fields under **Release and feedback via tags** that let the merchant control the hand-over:

| Field | Meaning |
|---|---|
| **Only take orders with this tag** | Empty: every open order is taken. With a tag (e.g. `Lager`): an order stays in the shop until the merchant gives it this tag in Shopify, so they can correct what the customer entered first. Case does not matter, other tags do not interfere. An order that is already taken keeps following Shopify (cancellation, fulfilment) whatever its tags. |
| **Set tag after take-over** | As soon as the order exists in X-Sitter, it gets this tag in Shopify (e.g. `X-Sitter`). The merchant sees in the shop which orders have reached the warehouse. Existing tags are kept. The app needs the `write_orders` scope for this; without it the order is still created and you get a Telegram message. |

A tag the merchant sets later is found by the next run of the job at the latest, even when newer orders have been taken meanwhile. Orders placed before the date in **Orders from** (*Bestellungen ab*) are not opened, tag or not.

**What the customer enters ends up in the note:** the note of the order, additional cart details and the properties of a line (e.g. the text of a greeting card or an engraving) go line by line into the note of the order, prefixed with the article name for lines, e.g. `Greeting card: Card text: All the best, Grandma!`. The properties are stored on the position as well. Internal app fields (name starting with `_`) are left out. The note is shown in the order details, during picking and at the packing station.

### Bundles and gift boxes as a set

If the shop sells bundles (Shopify Bundles app), for example a gift box made of three articles, Shopify only lists the components as positions in the order. Which box the customer ordered is then missing in the order: the warehouse sees loose articles and does not know what belongs together in one box. With the setting **Take in bundles (e.g. gift boxes) as a set** (*Bundles (z. B. Geschenkboxen) als Set übernehmen*) the bundle arrives in the order as a set.

1. Open **Administration › Jobs & connections** and there the job **Fetch orders** (`shopify-get-orders`) of the shop.
2. Under **Bundles from the shop** (*Bundles aus dem Shop*), choose **Yes - the bundle is listed with its SKU above its components** in the field **Take in bundles (e.g. gift boxes) as a set**.
3. Click **Save**.

From the next run on, the job additionally asks for the bundles of every new order and creates the order like this:

| Position | Content |
|---|---|
| **Head position** (the bundle) | SKU, name and quantity of the ordered box, without a price. It sits right above its components and is never picked. |
| **Components** | The articles of the box with their quantities (total quantity, not per box) and the prices the shop charged. |
| Other positions | Articles that belong to no bundle stay normal positions. |

This is what changes in the warehouse:

- **Order details and packing station** name the set below every component, e.g. "Set: 2 × Christmas Gift Box (GB-XMAS)" – quantity, name and SKU of the ordered box. The box itself is no row there. See [Order details](/orders/order-details.md) and [Packing](/outbound/packing.md#sets-and-gift-boxes).
- **Picking lists:** like any set, the box only leaves the warehouse complete. The order only gets onto a picking list once all components are in stock – unless partial delivery is allowed on the order. See [Orders with a set that cannot be delivered completely](/products/bills-of-materials.md#orders-with-a-set-that-cannot-be-delivered-completely).
- **Prices and customs papers:** Shopify spreads the price of the box over its components and invoices them that way. The components therefore keep their prices, the head position is in the order with 0.00. Customs papers keep declaring the components with their prices – as on the invoice of the shop.
- **Returns portal:** your customer returns the box as a whole; the portal shows the sum of its components as the price. See [Returns portal](/company/returns-portal.md).

![Screenshot: Products of an order with a gift box – three components with the badge "Set: 2 × Christmas Gift Box (GB-XMAS)" and one line without a set](/orders/images/order-details-set-hint.png)

Good to know:

- The setting applies to orders taken in from now on. Orders that already exist do not change.
- The article of the box does not have to exist in X-Sitter. If there is an article with the SKU of the box, the head position is linked to it; otherwise it only carries SKU and name.
- If the job cannot read the bundles of an order once (Shopify does not answer or the app lacks the `read_orders` scope), it does not create the order in this run and tries again in the next one – the order never arrives without its box. You get a Telegram message.
- With **No - the components come in as separate positions** (the default) everything stays as before: loose positions, the box is not named.
- If the shop sends a set as **one** position with its own SKU (some bundle apps), you do not need the setting – create a [bill of materials](/products/bills-of-materials.md) for it.

### Attaching the shop's invoice to the order

If the merchant creates invoices with a Shopify app such as **Order Printer Pro**, X-Sitter can fetch the invoice as a PDF when the order is created and attach it under **Documents** – handy for shipments to third countries (Switzerland, United Kingdom) where the invoice belongs to the customs papers.

1. In Order Printer Pro the merchant sets up the download link under **Automated PDFs › Set up PDF link** and sends you the link code (one line with the placeholders for the order id and the order number, `order.id` and `order.name`).
2. Paste the link into the job **Fetch orders** under **Invoice from the shop**, field **Invoice link of the shop app** – the whole line with `href="…"` works too.
3. Choose which orders get the invoice (**shipments outside the EU** or **all orders**) and whether it should be **printed at the packing station** – then the station prints it like an uploaded delivery note.

The invoice shows up in the order details under **Documents** with the kind **Invoice**. If an invoice cannot be fetched once (wrong link, shop answers with a page instead of a PDF), the order is still created and you get a Telegram message – attach the invoice by hand in that case.

## Tracking numbers back to Shopify

The job `shopify-send-tracking-back` reports the tracking numbers of sent orders to Shopify, so the order in the shop is fulfilled and the end customer is notified. This also works for shops connected through the X-Sitter app or a client app – they have no API key of their own. If one order or one shop fails, the job carries on with the next one; the failed order is tried again with the next run. If an order sits at the fulfillment service and its request has not been accepted yet, the job accepts it before reporting – Shopify refuses the tracking number without the acceptance.

## Good to know / Troubleshooting

Problems of the Shopify jobs reach you as the Telegram message **Shopify - error** (*Shopify - Fehler*) – set up [Telegram notifications](/account/telegram-notifications.md) to receive them. The same message is sent at most every few hours per shop.

| Message | Cause | Solution |
|---|---|---|
| *Der Shopify-App fehlen Rechte: … Bitte die App im Shop erneut autorisieren.* (the Shopify app lacks permissions) | The shop has not approved all permissions the jobs need. | Open the app in the Shopify admin and approve the requested permissions again. |
| *Fulfillment-Orders der Bestellung … nicht lesbar (HTTP 403: …). Der App fehlt das Recht read_merchant_managed_fulfillment_orders - bitte die App im Shop erneut freigeben.* | The app was installed before it asked for this permission, so the tracking numbers cannot be reported. | Approve the app in the shop again; the orders are reported with the next run. |
| *Shopify lehnt den Abruf der Fulfillment-Orders ab: …* (Shopify rejects fetching the fulfillment orders) | A permission is missing for the orders at the location. | Approve the app in the shop again. |
| *Das Lager im Shop konnte nicht eingerichtet werden: The location … set on the connection does not exist in the shop.* | The location ID entered by hand was deleted in the shop. | Empty or correct **Location ID** on the connection. |
| *… Problem(e) beim Bestandsabgleich: …* (problems in the stock sync) | Shopify rejected single articles, e.g. because the inventory ID belongs to a deleted product. | Run the product import again or correct the article. |
| *Die Bestellung … liegt seit … am Lager des Logistikers, der Händler hat in Shopify aber noch kein Fulfillment angefordert. …* (the merchant has not requested a fulfillment) | The merchant has not requested the fulfillment; without a request the warehouse does not take the order. | The merchant requests the fulfillment or turns on sending requests automatically. |
| *Die Fulfillment-Anfrage zur Bestellung … konnte nicht angenommen werden …* (the fulfillment request could not be accepted) | Shopify refused the acceptance, e.g. because the app lacks a permission or the merchant withdrew the request. | Read the reason in the message; the next run tries again. |
| *Der Händler möchte die Bestellung … stornieren, die Stornierung konnte aber nicht angenommen werden …* (the cancellation could not be accepted) | The warehouse has already started the order. | Stop the shipment and cancel the order, or clarify with the merchant. |
| *… hat der Händler selbst verschickt (in Shopify erfüllt, bevor das Lager sie begonnen hat). Die Aufträge stehen im Lager jetzt auf „Erledigt“: …* (shipped by the merchant, completed in the warehouse) | The merchant shipped the orders themselves. | Nothing to do, for your information only. |
| *… sind in Shopify bereits erfüllt (vom Händler selbst verschickt), das Lager hat die Aufträge aber schon begonnen. …* (fulfilled in Shopify, but the warehouse already started) | The merchant shipped while the order was already on a picking list or packed. | Stop the shipment, put the goods back, set the order to **Erledigt** and clarify with the merchant. |
| *Die Shopify-Bestellung … konnte nicht übernommen werden, der nächste Lauf versucht es erneut.* (the order could not be taken in, the next run tries again) with the reason "Shopify did not hand out the bundles of order …" | **Bundles as a set** is switched on and Shopify refused the request for the bundles of the order (overloaded, not reachable, or the app lacks the `read_orders` scope). | The next run usually takes care of it. If it persists: read the reason in the message and approve the app in the shop again – see [Bundles and gift boxes as a set](#bundles-and-gift-boxes-as-a-set). |
| *Shopify hat nicht geantwortet oder abgelehnt: …* (Shopify did not answer or refused) | The shop cannot be reached or the access is no longer valid. | Check the connection. |
| "This job already exists for this company, still without a connection …" | A job of this kind exists without a connection. | Choose the connection in the existing job first – see [Jobs & connections](/administration/jobs-and-connections.md). |
