Hi all,
Would appreciate some help, I am trying to manipulate some code so I can enable product variant quantities on our product pages but only show the quantities for variants that are tracked and “continue to sell when out of stock” is unchecked. The former is already used in the code, but the latter needs to be inserted.
{% if section.settings.stock_enable %}
- {% if current_variant.inventory_management %}
{% if current_variant.inventory_quantity < 10 and current_variant.inventory_quantity > 0 %}
{% assign qty = current_variant.inventory_quantity %}
{{ 'products.product.stock_available' | t: count: qty }}
{% elsif current_variant.inventory_quantity == 0 or current_variant.inventory_quantity < 0 and current_variant.incoming %}
{% if current_variant.available %}
{% assign date = current_variant.next_incoming_date | date: "%B %-d, %Y" %}
{{ 'products.product.will_not_ship_until' | t: date: date }}
{% else %}
{% assign date = current_variant.next_incoming_date | date: "%B %-d, %Y" %}
{{ 'products.product.will_be_in_stock_after' | t: date: date }}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
I have identified the variant object required to apply to the code but struggling to insert it correctly:
variant.inventory_policy
Returns the string continue if the “Allow users to purchase this item, even if it is no longer in stock.” checkbox is checked in the variant options in the Admin. Returns deny if it is unchecked.
Many thanks,
Mike
Ps. I have looked for the solution on the forum so apologies if this has been done before.