When to use:
Use this if you want the button to change to
Sold Out when the "
Allow customers to purchase this product when it's out of stock" is unchecked and inventory
quantity is <= 0.
Where has it been used:
This technique was first used on St. Vincent.
Function Breakdown:
- If inventory oversell is not checked and quantity is <= 0 then show sold out button
- If inventory oversell is checked then show normal button
- If inventory oversell is not checked show normal button
The Code:
Open product-add-to-cart-form.liquid and locate the purchase button. Replace the purchase button's code with the following.
{% assign trackInventory2 = true %}
{% for v in product.variants %}
{% if forloop.first == true %}
{% if v.inventory_policy == 'deny' %}
{% if v.inventory_quantity <= 0 %}
<input type="submit" name="add" value="SOLD OUT" id="purchase" class="btn-main purchase-btn {% if product.template_suffix == 'preorder' %}preorder-btn{% endif %}" disabled />
{% else %}
<input type="submit" name="add" value="{% include '__localize' with cart_label %}" id="purchase" class="btn-main purchase-btn {% if product.template_suffix == 'preorder' %}preorder-btn{% endif %}" />
{% endif %}
{% else %}
<input type="submit" name="add" value="{% include '__localize' with cart_label %}" id="purchase" class="btn-main purchase-btn {% if product.template_suffix == 'preorder' %}preorder-btn{% endif %}" />
{% endif %}
{% endif %}
{% endfor %}
Use left/right arrows to navigate the slideshow or swipe left/right if using a mobile device