Created
July 8, 2015 03:21
-
-
Save Cam/bf92f906076a7ef8ce75 to your computer and use it in GitHub Desktop.
Shopify Pre-Order Matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign preorders = 0 %} | |
{% for item in cart.items %} | |
{% if item.product.tags contains 'coming-soon' %} | |
{% capture preorders %}{{ preorders | plus: 1 }}{% endcapture %} | |
{% endif %} | |
{% endfor %} | |
{% if cart.item_count == 0 %} | |
{% if product.tags contains 'coming-soon' %} | |
<input type="submit" name="add" id="add" value="Pre-order Now" class="purchase button"> | |
<input type="hidden" name="return_to" value="/checkout" /> | |
{% else %} | |
<input type="submit" name="add" id="add" value="Add to cart" class="purchase button"> | |
{% endif %} | |
{% else %} | |
{% if preorders == 0 %} | |
{% if product.tags contains 'coming-soon' %} | |
<p class="warn">You have non pre-order items in your cart. Pre-order items must be ordered separately. Please <a href="/checkout">click here</a> to complete your order for the items that are already in your cart.</p> | |
<input type="submit" disabled="disabled" name="add" id="add" {% if product.tags contains 'coming-soon' %}value="Pre-order Now"{% else %}value="Buy now"{% endif %} class="purchase button"> | |
{% else %} | |
<input type="submit" name="add" id="add" value="Add to cart" class="purchase button"> | |
{% endif %} | |
{% else %} | |
{% if product.tags contains 'coming-soon' %} | |
<input type="submit" name="add" id="add" value="Pre-order Now" class="purchase button"> | |
<input type="hidden" name="return_to" value="/checkout" /> | |
{% else %} | |
<p class="warn">You have pre-order items in your cart. Pre-order items must be ordered separately. Please <a href="/checkout">click here</a> to complete your order for the items that are already in your cart.</p> | |
<input type="submit" disabled="disabled" name="add" id="add" {% if product.tags contains 'coming-soon' %}value="Pre-order Now"{% else %}value="Buy now"{% endif %} class="purchase button"> | |
{% endif %} | |
{% endif %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet stops people buying pre-order and non-pre-order items in the same checkout through a simple unobtrusive set of restrictions and messages