Show the remaining inventory of a variant on product pages
You can add a message on the product page or featured product section that displays the number of items you have in stock when inventory runs low on a product variant. For this message to display, you need to activate inventory tracking for the product.
The steps for this customization vary depending on your theme. Click the button for your theme and follow the instructions.
Debut
Steps for Debut
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% form 'product'
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{ current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit theme.js.liquid
or theme.js
The changes that you need to make to these files depend on the version of Debut that you're using.
Versions 17.8.0 and below
- Open
theme.js.liquid
ortheme.js
. -
Find
theme.Product = (function()
. Belowthis.selectors = {
, add the following code:
- In the same file, find
_updateAddToCart: function(evt) {
. Directly below, add the following code:
-
Find
if (variant.available) {
. Before the} else {
statement, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Versions 17.9.0 and above
- Open
theme.js.liquid
ortheme.js
. -
Find
theme.Product = (function()
. Belowthis.selectors = {
, add the following code:
- In the same file, find
_setProductState: function(evt) {
. Directly below, add the following code:
- In the same function, find
if (!variant) {
. After the closing}
bracket, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Brooklyn
Steps for Brooklyn
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% form 'product'
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit theme.js.liquid
or theme.js
- Open
theme.js.liquid
ortheme.js
. -
Find
theme.Product = (function()
. Belowthis.selectors = {
, add the following code:
- In the same file, find
if (variant.available) {
. Before the} else {
statement, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Simple
Steps for Simple
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% form 'product'
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit theme.js.liquid
or theme.js
- Open
theme.js.liquid
ortheme.js
. -
Find
theme.Product = (function()
. Belowthis.selectors = {
, add the following code:
- In the same file, find
if (variant.available) {
. Before the} else {
statement, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Minimal
Steps for Minimal
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% form 'product'
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit theme.js.liquid
or theme.js
- Open
theme.js.liquid
ortheme.js
. -
Find
theme.Product = (function()
. Belowthis.selectors = {
, add the following code:
- In the same file, find
if (variant.available) {
. Before the} else {
statement, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Boundless
Steps for Boundless
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% form 'product'
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit theme.js.liquid
or theme.js
- Open ‘theme.js.liquid’ *or *‘theme.js’.
-
Find
theme.Product = (function()
. Belowvar selectors = {
, add the following code:
- In the same file, find
$(selectors.SKU, this.$container).html(variant.sku);
. Directly below, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.
Narrative
Steps for Narrative
Edit theme.liquid
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click the ... button > Edit code.
- From the Layout directory, open
theme.liquid
. -
Find the closing
</head>
tag in the code. On a new line above the closing</head>
tag, paste the following code:
- Click Save.
Edit product-template.liquid
or featured-product.liquid
- From the Sections directory, open
product-template.liquid
orfeatured-product.liquid
:- Open
product-template.liquid
to add this feature to product pages. - Open
featured-product.liquid
to add this feature to the featured product section on the home page.
- Open
-
Find
{% include 'product-form' %}
. Above this tag, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include {{current_variant.inventory_quantity }}
in your <p>
tags.
- At the bottom of the file, add the following code:
- Click Save.
Edit custom.js
- Open
custom.js
. - At the bottom of the file, add the following code:
The code above outputs Stock: x
. You can change the wording by adjusting the content in the <p>
tags. Make sure to include ${variantStock[variant.id]}
in your <p>
tags.
- Click Save.