Skip to content

Instantly share code, notes, and snippets.

View bczegeny's full-sized avatar

Benjamin Czegeny bczegeny

  • Shopify
  • Vancouver, BC, Canada
  • 10:35 (UTC -07:00)
View GitHub Profile
@bczegeny
bczegeny / Validate_line_item-add_to_cart.md
Created February 26, 2016 19:07
This script will validate a line item property before adding to cart. You will need to update the selector name for your line item property. Also change the attr message and id to match your property/message
<script>
  $('#AddToCart').click(function() {
		$('#AddToCartForm').preventDefault();
    	if ( $('#serial-number').empty()) {
    	  	
          $('#serial-number').attr('placeholder','Enter your serial before adding to cart');
        } else {
          $('#AddToCartForm').submit();
 }
@bczegeny
bczegeny / Sort_by_vendor_Supply.md
Last active March 1, 2016 22:08
Sort by vendor dropdown for shop

Create a snippet place this code in it

{% if template contains 'index' %}
  <script>
  {% for product_vendor in shop.vendors %}
    $('#vendor-filter').append($('<option>', {
      value: '{{ product_vendor | url_for_vendor }}',
      text: '{{ product_vendor }}'
    }));
@bczegeny
bczegeny / 0_reuse_code.js
Created February 1, 2016 20:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console