Inventory Quantity

Inventory Quantity

saeedahmed0174
Tourist
7 0 2

I want to show inventory quantity less than or equal to 3 and using this code but it is showing me the sold out only.

{% assign current_variant = product.variants.first %}

<div class="inventoryNote form__label">
{% if current_variant.inventory_quantity > 0 and current_variant.inventory_quantity <= 3 %}
<p style="color: #D0DF00; text-align:center">ONLY {{ current_variant.inventory_quantity }} LEFT</p>
{% elsif current_variant.inventory_quantity <= 0 %}
<p style="color: #D0DF00; text-align:center">SOLD OUT</p>
{% else %}
<!-- Optionally handle cases where inventory is greater than 3 -->
<p style="color: #D0DF00; text-align:center">In stock</p>
{% endif %}
</div>
Replies 8 (8)

BSS-TekLabs
Shopify Partner
2350 702 828
{% assign current_variant = product.selected_or_first_available_variant %}

<div class="inventoryNote form__label">
  {% if current_variant.inventory_management == "shopify" %}
    {% if current_variant.inventory_quantity > 0 and current_variant.inventory_quantity <= 3 %}
      <p style="color: #D0DF00; text-align:center">ONLY {{ current_variant.inventory_quantity }} LEFT</p>
    {% elsif current_variant.inventory_quantity <= 0 %}
      <p style="color: #D0DF00; text-align:center">SOLD OUT</p>
    {% else %}
      <p style="color: #D0DF00; text-align:center">In stock</p>
    {% endif %}
  {% else %}
    <!-- If inventory management isn't handled by Shopify, optionally display nothing or handle it -->
  {% endif %}
</div>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
BSS-TekLabs
Shopify Partner
2350 702 828

Can you try this code @saeedahmed0174 

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
saeedahmed0174
Tourist
7 0 2

Picking the inventory of first avalaible variant

BSS-TekLabs
Shopify Partner
2350 702 828
{% assign first_available_variant = null %}

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

<div class="inventoryNote form__label">
  {% if first_available_variant %}
    {% if first_available_variant.inventory_quantity <= 3 %}
      <p style="color: #D0DF00; text-align:center">ONLY {{ first_available_variant.inventory_quantity }} LEFT</p>
    {% else %}
      <p style="color: #D0DF00; text-align:center">In stock</p>
    {% endif %}
  {% else %}
    <p style="color: #D0DF00; text-align:center">SOLD OUT</p>
  {% endif %}
</div>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
BSS-TekLabs
Shopify Partner
2350 702 828

Can you try this code

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
saeedahmed0174
Tourist
7 0 2

Not for selected variant

saeedahmed0174
Tourist
7 0 2

But this code pick the inventory of only first available variant and dono change when i select another varinat

 

saeedahmed0174
Tourist
7 0 2

My questions was about this It has same issue picking inventory for first avalaible variant not the selected one