-
-
Save zakhardage/7261874 to your computer and use it in GitHub Desktop.
// config -> settings.html | |
// Make sure you have the same number of quantity breaks as product variants | |
<fieldset> | |
<legend>Quantity Breaks</legend> | |
<table class="standard-table"> | |
<tr><td>Enter quantity breaks in ascending order separated by a comma (e.g. 5, 10, 20, 50)</td><td><input type="text" name="breaks" size="50" /></td></tr> | |
</table> | |
</fieldset> | |
// templates -> product.liquid | |
<table> | |
<tr><th>QTY</th><th>PRICE PER {{ product.options[0] }}</th></tr> | |
{% for variant in product.variants %} | |
<tr><td>{{ variant.title }}</td><td>{{ variant.price | money }}</td></tr> | |
{% endfor %} | |
</table> | |
<form action="/cart/add" method="post"> | |
<label>Quantity: </label> | |
<input type="text" id="quantity" name="quantity" onkeyup="quantityUpdate(this.value)" value="1" onclick="this.select()" /> | |
<input type="hidden" name="id" id="product-select" value="{{ product.variants[0].id }}" /> | |
<button type="submit"></button> | |
</form> | |
{% assign breaks = settings.breaks | split:', ' %} | |
<script type="text/javascript"> | |
function quantityUpdate(quantity){ | |
var qty = parseInt(quantity); | |
var break; | |
var variant = new Array(); | |
{% for variant in product.variants %} | |
variant[{{ forloop.index | minus:1 }}] = "{{ variant.id }}"; | |
{% endfor %} | |
{% for break in breaks reversed %} | |
break = parseInt({{ break }}); | |
if(qty < break) {document.getElementById("product-select").value = variant[{{ forloop.index | minus:1 }}];} | |
{% endfor %} | |
} | |
</script> |
Anyone figure this out? Same question as the last two....
For those of you wondering where to edit the liquid as indicated ... look at the raw README.md file here: https://raw.githubusercontent.com/zakhardage/Tiered-Pricing/master/README.md
I think something got stripped out when he was trying to add that file - GitHub's markdown is a little different than other varieties, or so I've been told.
What's missing is this:
Find <form action="/cart/add" method="post"> ... </form>
I'm not sure how to 'wrap' in the code, do I just paste in the segment ?
has anyone successfully implemented this? it seems to me to just be a variant...doesn't actually pull from the same inventory entry...
Does Anyone know how to implement this. I follow the steps, it seems like adding a variant which can't update the price automatically?
I have a better solution.
see example:
https://www.umbrellabazaar.com/collections/fashion-umbrellas/products/wholesale-solid-color-hook-umbrella
https://tote-4.myshopify.com/collections/wholesale-non-woven-tote-bags
Each product have its own qty break values. Skype aaliyan2050
Any one has a solution without creating a variant per rate?
Let us know too,
thanks
Hi, I'm also having the same issue as floetry described above. Please let us know where we need to add the code to include tiered-pricing. Thank you in advance. I am also attempting to utilize the update code.