# Count stock by market with Markets & locations Markets & locations lets you choose which Shopify locations XFlow uses to calculate stock for each market. XFlow uses this stock to decide when to show the **Pre-order** button and which subscribers receive a restock alert, so shoppers only see offers for stock that can reach them. ## How XFlow calculates stock XFlow calculates available stock differently depending on whether **Markets & locations** is enabled. | Markets & locations | How XFlow calculates stock | | ------------------- | ------------------------------------------------------------------------------------------------------ | | **Off** | Counts stock from all locations that fulfill online orders. All markets share the same stock quantity. | | **On** | Counts stock separately for each market based on its assigned locations. |
A product is considered out of stock when its available stock is 0 or below. ## Set up Markets & locations Make sure that: * Set up your markets in Shopify. Learn how to [create and activate markets](https://help.shopify.com/en/manual/markets/getting-started/set-up-markets). * Turn on **Fulfill online orders** for each location that ships orders to customers. XFlow counts only the locations that fulfill online orders. * Approve the access request that XFlow displays when you open the app. XFlow requires this access to read your markets and shipping settings. If your store uses location-based notifications by country, follow [Switch from notifications by country to Markets & locations](https://docs.foxecom.com/xflow-app/store-management/count-stock-by-market-with-markets-and-locations/switch-from-notifications-by-country-to-markets-and-locations) instead. 1. Go to **XFlow > General settings**. 2. Click **Markets & locations**. 3. Click **Turn on** next to **Track inventory by market and locations**. 4. Click **Save**. By default, each market tracks inventory from all locations that fulfill online orders. You can customize the locations for each market. ![Markets & locations in XFlow General settings, with Track inventory by market and locations turned on and the Edit button next to each market highlighted](https://docs-assets.foxecom.app/xflow-app/89826e96-3ad3-4ad7-87e4-509c9741d013.png) 1. Click **Edit** next to the market. 2. Choose **All locations that fulfill online orders** or **Only the locations I choose**. 3. Select the locations to count, if you chose **Only the locations I choose**. Use the search box, **Select all** or **Clear** to make the selection faster. 4. Click **Save** in the window. 5. Click **Save** on the page. Each market uses one of two location settings: | Location setting | What XFlow counts | Use it when | | -------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------ | | **All locations that fulfill online orders** | Stock from every location that fulfills online orders, including locations added later. | Different markets ship from different locations. | | **Only the locations I choose** | Stock from the locations you select for that market. | Different markets ship from different locations. |
![inventory locations](https://docs-assets.foxecom.app/xflow-app/91741bc9-b89e-42fe-92fa-350222e68ea1.png) You have 3 inventory locations: * US warehouse: 10 units. * Vietnam warehouse: 0 units. * Retail store: 5 units (does not fulfill online orders). If you assign the US warehouse to the United States market and the Vietnam warehouse to the Asia market, the product is **in stock in the United States** but **out of stock in Asia**. The retail store's inventory is excluded. XFlow does not verify which locations ship to a market. Select locations that ship to that market, so that customers do not see a Pre-order button or receive an alert for stock that cannot reach them.
## How market stock affects back in stock and pre-orders When Markets & locations is enabled, XFlow uses the customer's country to identify their market and determine the available stock. ### When a restock alert is sent  XFlow identifies the subscriber's market based on the country entered at sign-up. A restock alert is sent when stock in that market reaches the minimum restock quantity saved with the subscription. * Restocks at locations outside the market's assigned locations do not trigger alerts for that market. * Customers can still sign up for restock alerts regardless of the selected locations. * Restock alerts can still be sent while the **Pre-order** button is displayed. ### When the Pre-order button shows The Pre-order button appears when all three conditions are met: * **Track quantity** and **Continue selling when out of stock** are enabled for the variant. * An active Pre-order campaign includes the variant and the customer's market. * The market's stock matches the campaign's display setting. Using the inventory example above, if a Pre-order campaign includes both markets and uses **When out of stock**, customers in Asia see **Pre-order**, while customers in the United States see **Add to cart**. If a market is out of stock and is not included in the product's Pre-order campaign, XFlow replaces **Add to cart** with a disabled **Out of stock** button. This only affects the storefront display. ## Check inventory locations for each market Some locations may not be included in a market's stock calculation: * **Disabled location:** The location does not fulfill online orders. To include its stock, enable **Fulfill online orders** in Shopify. * **Market with 0 stock:** If none of the selected locations fulfill online orders, XFlow counts the market's stock as 0. You can still save your selection. ## Use markets in a Pre-order campaign When Markets & locations is enabled, you can choose which markets your Pre-order campaign applies to. 1. Open your Pre-order campaign. 2. Go to the **Markets** section, directly below **Products**. 3. Choose **All markets** or **Specific markets**. 4. If you choose **Specific markets**, select the markets you want to include. Each market displays the inventory locations XFlow counts for it. 5. Save the campaign. When Markets & locations is off, every campaign runs in **All markets**, and the **Markets** section shows a link to turn the setting on. See [Create a pre-order campaign](https://docs.foxecom.com/xflow-app/pre-order/create-a-pre-order-campaign). ![Use markets in a Pre-order campaign](https://docs-assets.foxecom.app/xflow-app/66e59654-00fb-4def-bc25-74b937f1582f.png) ## FAQs No. Shoppers already waiting for a restock keep their subscriptions. From then on, each subscriber gets an alert based on the stock in the market that includes their country. No. XFlow doesn't use shipping settings to decide when to show a button or send an alert. Select the locations that ship to each market. No. After you switch, Notification by country is permanently turned off. See [Switch from notifications by country to Markets & locations](https://docs.foxecom.com/xflow-app/store-management/count-stock-by-market-with-markets-and-locations/switch-from-notifications-by-country-to-markets-and-locations). ## Related articles Switch from notifications by country to Markets & locations Manage notification rules and subscriber data Set up your back in stock campaign Create a pre-order campaign