1
votes

I am simply allowing to checkout out of stock product to buy. When a customer wants to buy product has inventory less than zero and clicks on view cart from ajax cart, I simply want to show message " dispatch by 7 June." in cart-template.liquid.I have applied logic as given below. If required full code ready to share.

{% if variant.inventory_quantity < 1%}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{{variant.inventory_quantity}}
{% endif %}
<script>console.log(variant.inventory_quantity)</script>

when I print the message in cart-template.liquid without if condition I can see this message. I found that it does not print anything inside {{}} also checked with console.log gives error as variant is not defined My query Is do I need to define variant manually? if yes how? or need to use a different liquid variable to check inventory quantity of product less than zero? Let me know if any more are required. Thanks.

1

1 Answers

0
votes

I have started printing all variant variable. I just simply added item before variant.inventory_quantity and it saves my day.

{% if item.variant.inventory_quantity < 1 %}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{% endif %}