Anonymous Anonymous - 6 months ago
1049 0

No description

Other

Brooklyn-stuff

{% comment %}

  *IMPORTANT:*
  This theme uses a customized version of `option_selection.js` to support using radio inputs for
  color and size variants. The custom version is in `variant_selection.js`.

  If you wish to enable the default dropdowns for size and color
  you can change the liquid asset tag below from:

  {{ 'variant_selection.js' | asset_url | script_tag }}

  to

  {{ 'option_selection.js' | shopify_asset_url | script_tag }}

  If you use the default `option_selection.js` the labels for the dropdowns will
  appear outside the dropdown.

  You will also need to change `.radio-wrapper` to `.selector-wrapper` below.

{% endcomment %}
{{ 'variant_selection.js' | asset_url | script_tag }}
<script>
  var selectCallback = function(variant, selector) {
    if (variant.inventory_quantity < 1 && variant.available) {
    $("#atc-notify").removeClass("out-stock-show");}
    else {$("#atc-notify").addClass("out-stock-show");};
    
    timber.productPage({
      money_format: "{{ shop.money_format }}",
      variant: variant,
      selector: selector,
      translations: {
        addToCart : {{ 'products.product.add_to_cart' | t | json }},
        soldOut : {{ 'products.product.sold_out' | t | json }},
        unavailable : {{ 'products.product.unavailable' | t | json }}
      }
    });
    
  };

  jQuery(function($) {
    new Shopify.OptionSelectors('ProductSelect', {
      product: {{ product | json }},
      onVariantSelected: selectCallback,
      enableHistoryState: true
    });

    // Add label if only one product option and it isn't 'Title'. Could be 'Size'.
    {% if product.options.size == 1 and product.options.first != 'Title' %}
      $('.radio-wrapper:eq(0)').prepend('<label for="ProductSelect-option-0" class="single-option-radio__label">{{ product.options.first | escape }}</label>');
    {% endif %}

    // Hide drop-down selectors if we only have 1 variant and its title contains 'Default'.
    {% if product.variants.size == 1 and product.variants.first.title contains 'Default' %}
      $('.selector-wrapper').hide();
    {% endif %}
  });
</script>
<script>
  $(document).ready(function() {
    $('ul.tabs').each(function(){
      var active, content, links = $(this).find('a');
      active = links.first().addClass('');
      content = $(active.attr('href'));
      links.each(function () {
        $($(this).attr('href')).hide();
      });
      $(this).find('a').click(function(e){
        active.removeClass('active');
        content.hide();
        active = $(this);
        content = $($(this).attr('href'));
        active.addClass('active');
        content.show();
        return false;
      });
    });
  });
</script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download