Skip to content

Instantly share code, notes, and snippets.

@Cam
Created July 8, 2015 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cam/bf92f906076a7ef8ce75 to your computer and use it in GitHub Desktop.
Save Cam/bf92f906076a7ef8ce75 to your computer and use it in GitHub Desktop.
Shopify Pre-Order Matrix
{% 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 %}
@Cam
Copy link
Author

Cam commented Jul 8, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment