How To Fix Out Of Stock Message

How To Fix Out Of Stock Message

Nathanle8
Tourist
7 0 1

I am trying to make it so that when using the availability filters, the items that are labeled "Out of Stock" is truly out of stock for ALL variants. The problem is that some of my products has certain sizes that are sold out, but not all sizes are sold out. How would I fix this, I am using the Impulse theme.

Nathanle8_0-1720126055535.pngNathanle8_1-1720126083189.png

 

Reply 1 (1)

EcomGraduates
Shopify Partner
764 67 112

You want to ensure that items marked as "Out of Stock" are truly out of stock for all variants, not just specific sizes. To achieve this in the Impulse theme, you’ll need to customize the code to check the stock levels of all variants before displaying the product as out of stock.

Here's a simplified approach:

  1. Check Stock Levels: Modify the code to loop through all variants of a product and determine if the product is truly out of stock.

  2. Display Logic: Adjust the display logic to only mark a product as "Out of Stock" if all its variants are out of stock.

Here's a basic example of how you might implement this:

  1. Edit the theme code: Go to your Shopify admin, then "Online Store," "Themes," and "Edit code."

  2. Find the relevant Liquid template: Look for the product grid or collection template file, often found in the "Sections" or "Snippets" folder, such as collection-template.liquid.

 

{% assign all_sold_out = true %}
{% for variant in product.variants %}
  {% if variant.inventory_quantity > 0 %}
    {% assign all_sold_out = false %}
    {% break %}
  {% endif %}
{% endfor %}

{% if all_sold_out %}
  <div class="product out-of-stock">
    <p>Out of Stock</p>
  </div>
{% else %}
  <div class="product in-stock">
    <p>In Stock</p>
  </div>
{% endif %}

 

 

This code checks if all variants are sold out and only then marks the product as "Out of Stock." Adjust the HTML and classes as needed to fit your theme’s structure.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner