Liquid, JavaScript, themes, sales channels
I wanted to know how to remove the quantity selector on cart page when I have one product in the inventory available. If there is more than one product in the inventory, I want the quantity selector to show. I believe I need to edit this part of the code:
<td data-quantity data-label="{{ 'cart.label.quantity' | t }}">
{% if current_variant.inventory_quantity == 1 %}
<div>NONE</div>
{% else %}
<div class="flex items-center hidden lg:block">
<button
type="submit"
class="w-6 p-1 align-middle"
@Click.prevent="qtyAdjust($event, -1, 'quantity_{{ item.key | replace: ':', '' }}')"
:aria-label="'{{ 'general.accessibility.decrement_one' | t }} ' + '{{ item.title }}'">
{% render 'icon-minus' %}
</button>
<input type="text"
name="updates[]"
id="updates_{{ item.key }}"
value="{{ item.quantity }}"
class="min-w-0 w-6 pb-1 text-center text-sm lg:text-base border-b-text border-current bg-transparent"
min="0"
aria-label="{{ 'cart.label.quantity' | t }}"
pattern="[0-9]*"
x-model.number="quantity_{{ item.key | replace: ':', '' }}"
autocomplete="off" />
<button
type="submit"
class="w-6 p-1 align-middle"
@Click.prevent="qtyAdjust($event, 1, 'quantity_{{ item.key | replace: ':', '' }}')"
:aria-label="'{{ 'general.accessibility.increment_one' | t }} ' + '{{ item.title }}'">
{% render 'icon-plus' %}
</button>
</div>
{% endif %}
</td>
I added
{% if current_variant.inventory_quantity == 1 %}
<div>NONE</div>
{% else %}
but it is not working.
Thanks for your help!
Solved! Go to the solution
This is an accepted solution.
Hello, @dhsk11
Use
{% if item.variant.inventory_quantity == 1 %}
Instead of
{% if current_variant.inventory_quantity == 1 %}
This is an accepted solution.
Hello, @dhsk11
Use
{% if item.variant.inventory_quantity == 1 %}
Instead of
{% if current_variant.inventory_quantity == 1 %}
Thank you very much! That worked perfectly.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024