Minimum quantity and Barcode

Highlighted
Tourist
13 0 1

Hi 

I'm running simple theme, and it's important for me to have a minimum quantity buy for each variant, as a wholesale site.

Since I could not find the perfect solution for this in the forum, I decided to use the "Barcode" as my minimum quantity value, since I'm not using this for anything.

In product-template.liquid I added the code below, and barcode value is now displayed in my quantity box for each variant, and this works great. 

 

Min. Quantity <input type="text" name="quantity" value = "{{ current_variant.barcode }}" size="4" style="width:60px;">

In cart.liquid I added the code 

<!-- For minimum order quantities Start-->
{% assign batchesok = true %} {% for item in cart.items %} <tr> <td class="image"> <div class="product_image"> <a href="{{ item.product.url }}"> <img src="{{ item.product.featured_image | product_img_url: 'small' }}" alt="{{ item.product.title }}" /> </a> </div> </td> <td class="item"> <a href="{{item.product.url }}"> <strong>{{ item.product.title }}</strong> {% if item.product.variants.size > 1 %} <span class="variant_title">{{ item.variant.title }}</span> {% endif %} </a> </td> <td class="qty"> <input type="text" size="4" name="updates[]" id="updates_{{ item.id }}" value="{{ item.quantity }}" onfocus="this.select();" class="tc item-quantity" /> </td> <td class="errormessage"> {% unless item.variant.barcode == NAN %} {% assign batching = item.variant.barcode %} {% capture modulo %}{{ item.quantity | modulo: item.variant.barcode }}{% endcapture %} {% unless modulo == '0' %} {% assign batchesok = false %} Must order in multiples of <strong>{{ item.variant.barcode }}</strong> {% endunless %} {% endunless %} </td> <td class="price">{{ item.line_price | money }}</td> <td class="remove"><a href="/cart/change?line={{ forloop.index }}&quantity=0" class="cart">Remove</a></td> </tr> {% endfor %} <tr class="summary"> <td class="image">&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td class="price"><span class="total"><strong>{{ cart.total_price | money }}</strong></span></td> <td>&nbsp;</td> </tr> </tbody> </table> {% unless batchesok %} <div class="span12 errormessagebox" id="batch"> {% for item in cart.items %} {% unless item.variant.barcode == NAN %} {% assign batching = item.variant.barcode %} {% capture modulo %}{{ item.quantity | modulo: item.variant.barcode }}{% endcapture %} {% unless modulo == '0' %} <p>You must order <strong>{{ item.product.title }}</strong> in multiples of <strong>{{ item.variant.barcode }}</strong></p> {% endunless %} {% endunless %} {% endfor %} </div> {% endunless %} <!-- For minimum order quantities END--> <!-- For minimum order quantities START--> <script> <script> $(function(){ var $cartform = $('#cartform'); $cartform.find('.item-quantity').change(function(){ console.log("changed quantity"); $cartform.find("#checkout").attr("disabled","true"); }); }) </script>
<!-- For minimum order quantities END-->

But this Barcode value do not update if I user select variant, If I have a large airplane with barcode 1 (minimum quantity) and a Small airplane with barcode 10 (minimum quantity) and user select between the 2, the barcode (minimum quantity) do not update, can someone help out with this?

 

All the best

 

0 Likes