All things Shopify and commerce
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>
{% 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
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
Picking the inventory of first avalaible variant
{% 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
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
Not for selected variant
But this code pick the inventory of only first available variant and dono change when i select another varinat
My questions was about this It has same issue picking inventory for first avalaible variant not the selected one
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024