How to show low stock alert ("Only 3 left") on Xtra Theme to boost conversions?

Topic summary

A Shopify store owner using the Xtra theme wants to add a low-stock alert (e.g., “Only 3 items left”) to product pages to create urgency and reduce cart abandonment.

Main Solution Provided:

  • Edit main-product.liquid (or product-form.liquid) in the theme code
  • Add Liquid code to check inventory quantity and display a message when stock falls below a threshold (typically 5 or fewer items)
  • Style the alert with CSS including optional pulse animation for emphasis
  • Ensure “Track quantity” is enabled in Shopify product settings

Key Considerations:

  • The original poster is dropshipping without actual inventory tracking, which may prevent the solution from working as it relies on Shopify’s inventory data
  • One commenter warns against editing theme files directly, recommending using custom liquid/HTML blocks within the product section instead to avoid breaking the theme
  • Variant selection compatibility varies by theme—some solutions may not update the stock message when customers switch between product variants
  • An app recommendation (ScarcityPro+ Quantity & Timer) was offered as an alternative that handles dynamic stock alerts with filtering and customization options

Status: Multiple code solutions provided, but implementation challenges remain due to dropshipping model and variant behavior concerns.

Summarized with AI on October 24. AI used: claude-sonnet-4-5-20250929.

Hi everyone :waving_hand:

I’m using the Xtra theme on my Shopify store, and I’m trying to reduce cart abandonment and increase urgency for customers who add items to the cart but don’t complete checkout.

I’d like to add a low-stock message like:

“Only 3 items left – order now before it’s gone!”

I believe this could help improve conversions and push customers to complete their purchase.

Can anyone help me with how to implement this in Xtra theme? I’m open to using custom code or an app if needed, but I’d prefer something lightweight and clean-looking.

Appreciate any tips or examples - thanks a lot in advance :folded_hands:

1 Like

Hi @EagleHunted ,
Go to online store → themes → edit code → sections → product-template.liquid
look for something like this :

{{ product.selected_or_first_available_variant.inventory_quantity }}

If you don’t see it, insert this line manually to get the inventory:

{% assign inventory = product.selected_or_first_available_variant.inventory_quantity %}

then add the low stock message below the inventory assigenment

{% if inventory > 0 and inventory <= 5 %}
  <p class="low-stock-message" style="color: red; font-weight: bold;">
    Only {{ inventory }} item{% if inventory > 1 %}s{% endif %} left – order now before it’s gone!
  </p>
{% endif %}

then add css go to assets → base.css or theme.css
add this at the bottom

`.low-stock-message {
  font-size: 16px;
  margin-top: 10px;
  color: #d32f2f;
  animation: pulse 1.2s infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.6; }
}
`

save and refresh preview.

If I was able to give you solution, please don’t forget to like and mark it as the solution.
If you need further assistance, feel free to reach out to me.
Thanks
Manoj

Hi Cherry,

Thanks so much for the helpful tip! I really appreciate it.

However, I’m having a little trouble locating the main-product.liquid or product-information.liquid files in my theme. Could you let me know where exactly I can find them? Or maybe they’re named differently in my theme?

Also, I’d like to set the stock limit to a different number, say 3, instead of 5. Could you point me to where I can make that change in the code?

Thanks again for your help!

Best regards,


Hi Manoj,

Thank you so much for the detailed instructions! I really appreciate the help.

However, I’m having some trouble locating the product-template.liquid file in my theme. Could you guide me on where I can find it? Or maybe it’s named differently in my version?

Thanks again for your support!

Best regards,


@EagleHunted
its main-product.liquid

Hi @Cherry1
Thank YOU so much for the help. I appreciate it

I’ll check out the product-main.liquid file like you mentioned ,Just to clarify, I don’t have inventory since I’m dropshipping. Will the low-stock message still show up, or does it only work if there’s actual inventory in the system? cause you mentioned the message will show when the inventory is 3 or fewer

Thanks again

1 Like

Sigh, @EagleHunted don’t edit theme files directly first.
First check if that template has a custom-html/custom-liquid block and use that first.

Otherwise BACKUP your theme before following forums any posts that have you mucking in files code.

And depending on theme behavior most “solutions” won’t work with variant selection or other considerations.

1 Like

Hi @PaulNewton thanks for the heads-up!

Just to clarify : are you suggesting I should add the code inside the product page using a “custom liquid or custom HTML” section if available?

My theme does have both of those blocks as sections, but I’m not entirely sure where exactly the code should go, inside the product template or on the product page content or the theme code?

Also, regarding your note on variants not working with most “solutions” , could you explain a bit more? Are you referring to the variant selector not updating prices/images/etc if I use custom blocks instead of editing the core theme files?

I appreciate the help!

Look in the product info section itself for such a block, not a new section.
NOT a section , for product/variant specific behavior it’s need to be a BLOCK,
You can just try a section separate from the product-info/product-form but likely it will NOT update when variants change unless a theme specifically has that behavior.

The variant selector + block behavior varies by themes, sometimes they are wired together other times not.
This also apples to just slapping html into a file it wont always automagically update.

If it doesn’t work then it’s deeper work.
For services to get this done properly click my profile pic for direct options.
Or PM me, or request here that I PM you.

Hi, I’m Nathan from Axeon.

If you’d like to display a low stock alert such as “Only 3 left” on your product pages, our app ScarcityPro+ Quantity & Timer can handle this out of the box. You can:

Show the alert only when inventory falls below a threshold you choose, or always display a live dynamic quantity.

Filter by product tags or product names so the alert only appears on specific products.

Fully customize the text, colors, fonts, and layout so it blends seamlessly with your theme, including Xtra.

If you’d like, I can provide a quick walkthrough so you can see how it looks in action!

Hi there :waving_hand:

You’re on the right track — showing a low-stock message can really help reduce cart abandonment and encourage customers to check out faster. Here’s a clean, lightweight way to add it directly in your Xtra theme without needing an app:


Step 1: Edit Your Product Template

  1. Go to Online Store > Themes > Xtra > Edit code.

  2. Open your product template file — usually named main-product.liquid or product-form.liquid (depending on your theme version).

  3. Find the section where your Add to Cart button or product information is displayed.

  4. Right above or below the Add to Cart button, paste this code:

{% if product.selected_or_first_available_variant.inventory_management == "shopify" %}
  {% assign stock = product.selected_or_first_available_variant.inventory_quantity %}
  {% if stock > 0 and stock <= 5 %}
    <p class="low-stock-msg">
      Only {{ stock }} item{% if stock > 1 %}s{% endif %} left – order now before it’s gone!
    </p>
  {% endif %}
{% endif %}

:backhand_index_pointing_right: You can adjust the number 5 to any threshold you want (for example, show the message only when stock is less than or equal to 3).


Step 2: Add CSS for Styling

  1. In the same code editor, go to your theme’s main CSS file (usually base.css or theme.css).

  2. Scroll to the bottom and paste this CSS:

.low-stock-msg {
  color: #d9534f; /* red urgency color */
  font-weight: 600;
  margin-top: 10px;
}

This will style the message so it stands out in red and looks professional.


Step 3: Make Sure Inventory Is Tracked

  • Go to your product settings in Shopify.

  • Make sure “Track quantity” is enabled.

  • Without this, Shopify won’t know how many items are left, and the message won’t display.


:white_check_mark: That’s it! Now when a product’s stock is low (e.g., 5 or less), customers will see a message like:
“Only 3 items left – order now before it’s gone!”