# Stock level indicator

{% hint style="danger" %} <mark style="color:red;">Theme retirement</mark> Ira is no longer available on the Shopify theme store. **Theme support and updates for current users will end after May 18, 2024**. [Learn more here](https://help.fluorescent.co/ira/readme/theme-retirement).
{% endhint %}

In the Product template, the **Stock level indicator** displays the relative availability of your product with a dynamic indicator bar that alerts customers when there are limited quantities.

Displaying your stock level can turn limited stock quantities into an advantage by conveying a sense of scarcity to increase conversion and quicker purchases.

The indicator bar visually represents the remaining percentage of your initial stock quantity, turns red when stock is low, and displays three different messages.

## Set up stock level indicator

{% hint style="success" %} <mark style="color:green;">**Shopify**</mark> | Before adding a **Stock level indicator** block, you need to enable the **Track quantity** option for your product and product variants. See the Shopify guide about how to [set up inventory tracking](https://help.shopify.com/en/manual/products/inventory/track_inventory#set-up-inventory-tracking).
{% endhint %}

Follow the steps below to set up the stock level indicator block, and enter a inventory base quantity and low level threshold.

<details>

<summary><mark style="color:blue;"><strong>STEPS</strong></mark></summary>

In your theme editor (**Customize**):

1. Select a **Products** template you want to edit.
2. Click **(+) Add block** and select **Stock level indicator** from the Theme Blocks list.
3. Click on the new **Stock level indicator** block to open the settings.
4. (*Optional*.) Toggle the **Show label** option to display or hide the "Stock" title above the indicator bar.
5. Enter the initial quantity of your product stock level in the **Inventory base quantity** field.

   > The indicator bar displays your remaining product quantity as a percentage of this base quantity. If your base quantity is set at 100 products, the bar will display at 100% when your have 100 products in stock and 60% when you have 60 products in stock.

   > To learn how to set different base quantities for multiple products, see the [steps for using dynamic sources and metafields](#use-dynamic-sources-for-multiple-products).
6. Enter the product inventory quantity in the **Low quantity threshold** to alert customers when limited quantities are available.

   > When your current product inventory matches or goes below the *Low quantity threshold*, the indicator bar will turn red and display a "Limited quantities available" message.

   > To learn how to set different *Low inventory thresholds* for multiple products, see the [steps below for using dynamic sources and metafields](#use-dynamic-sources-for-multiple-products).
7. (*Optional*.) Click and hold the drag handles **`⋮⋮`** to rearrange the blocks:

   ![](https://4075298574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F072gQRkuxS6ZiYGtqLNG%2Fuploads%2Fgit-blob-22765d66f3708b95b5907a71e6b24326594ad146%2Fshopify-content-drag-handles.jpeg?alt=media)

   > Click **Remove block** in the block settings to delete a block.

   > Click the **Eye icon** to hide or unhide a block.
8. Click **Save**.

</details>

## **Use dynamic sources for multiple products**

If you need to set a different **Inventory base quantity** and **Low inventory threshold** for multiple products, you can use Shopify's **metafields** and **dynamic sources**.

Follow the steps below to create metafields for your products, add inventory numbers to those metafields, then use **Dynamic sources** to connect metafields to the stock level settings in your theme editor.

> For a general introduction, see our [Dynamic sources and metafields tutorial](https://help.fluorescent.co/ira/general/adapting-your-theme/dynamic-content-with-metafields).

### **1. Create number metafield**

Shopify's **Metafields** lets you store additional information about your products. You can create custom fields to hold different types of information in your Shopify admin, and enter unique content for each of your products.

The steps below show you how to add two **Number** metafields for storing an **inventory base quantity** and **Low stock threshold**.

<details>

<summary><mark style="color:blue;"><strong>STEPS</strong></mark></summary>

In your theme editor (**Customize**):

1. Click the **Stock Level Indicator** block to open the settings.
2. Next to the **Inventory base quantity** field, click the **Insert dynamic source** button and select **(+) Add Metafield**.
3. Click the **Products** tab.

   ![](https://4075298574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F072gQRkuxS6ZiYGtqLNG%2Fuploads%2Fgit-blob-0faa0d0960ece34cf4f568c8325e4059beada7c7%2Fmetafield-product.jpeg?alt=media)
4. Click the **Add definition** button in the top-right.
5. Add a **Name** to the metafield that describes what it will be used for.

   > We recommend naming the metafield the same as the setting name: "Inventory base quantity" or "Low stock threshold".

   ![](https://4075298574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F072gQRkuxS6ZiYGtqLNG%2Fuploads%2Fgit-blob-b19d4d84327b9dab5462737deb216e36f9b4c836%2Fmetafield-definition-name.jpeg?alt=media)
6. Click **(+) Select type** button and select **Number**.
7. (*Optional*.) Repeat steps 4 - 5 to add another metafield for **Low stock threshold**.
8. Click **Save**.

</details>

### **2. Add quantity to number metafields**

Once you've created number **Metafields** for your products, you can now add quantities those fields by going to your products in the Shopify admin.

<details>

<summary><mark style="color:blue;"><strong>STEPS</strong></mark></summary>

In your **Shopify Admin**:

1. Go to your **Product inventory** in your Shopify admin and open one of your **Products**.

   ![](https://4075298574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F072gQRkuxS6ZiYGtqLNG%2Fuploads%2Fgit-blob-ba6779753d96402956a9813479e339a0ef63dc5d%2Fadmin-product-inventory.jpeg?alt=media)
2. Scroll down to the **Metafields** section.
3. Enter the **Inventory base quantity** or **Low quantity threshold** that you want for the product.

   ![](https://4075298574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F072gQRkuxS6ZiYGtqLNG%2Fuploads%2Fgit-blob-a9564b87d2b92360e8533b36a8734c41c7afc197%2Fstock-indicator-metafield-quantity.jpeg?alt=media)
4. Repeat steps 1 - 3 to add the different quantities to the metafields of the products you want to display a Stock level indicator.
5. Click **Save**.

</details>

### **3. Insert metafields as dynamic sources**

Now that the **Metafields** of your products have content, you can go to the theme editor to insert a **Dynamic source** to the **Stock level indicator** settings in the **Products** template.

<details>

<summary><mark style="color:blue;"><strong>STEPS</strong></mark></summary>

In your theme editor (**Customize**):

1. Click the **Stock Level Indicator** block to open the settings.
2. Delete the current quantity in the **Inventory base quantity** so the field is left blank.
3. Click the **Insert dynamic source** button next to **Customer product list**

   ![](https://github.com/fluorescent/kb-ira/blob/main/.gitbook/assets/dynamic-source-example.jpeg)
4. Select the "Inventory base quantity" metafield you create.
5. (*Optional*.) Click the **Dynamic source** button next to the **Low stock threshold** to add a "Low stock threshold" metafield.
6. You can now preview your store to confirm the correct product list appears when viewing different products.
7. Click **Save**.

</details>

<br>

***

> **Related links**
>
> [Product template](https://github.com/fluorescent/kb-ira/blob/main/product-pages/product-pages/product-template.md)\
> [Metafields and dynamic sources](https://help.fluorescent.co/ira/general/adapting-your-theme/dynamic-content-with-metafields)
