'); // Update description var quickShop_Description=$(selectedProduct.description).text(); quickShopDescription.html(quickShop_Description.substring(0,139)+"..."); // Generate variants var productVariants = selectedProduct.variants; var productVariantsCount = productVariants.length; quickShopPriceContainer.html(''); quickShopVariantsContainer.html(''); quickShopAddToCartButton.removeAttr('disabled').fadeTo(200,1); if (productVariantsCount > 1) { // Reveal variants container quickShopVariantsContainer.show(); // Build variants element var quickShopVariantElement = $(' ',{ 'id': ('quick-shop-variants-' + selectedProductID) , 'name': 'id'}); var quickShopVariantOptions = ''; for (var i=0; i < productVariantsCount; i++) { quickShopVariantOptions += ''+ productVariants[i].title +'' }; // Add variants element to page quickShopVariantElement.append(quickShopVariantOptions); quickShopVariantsContainer.append(quickShopVariantElement); // Bind variants to OptionSelect JS new Shopify.OptionSelectors(('quick-shop-variants-' + selectedProductID), { product: selectedProduct, onVariantSelected: selectOptionCallback }); // Add label if only one product option and it isn't 'Title'. if (selectedProduct.options.length == 1 && selectedProduct.options[0] != 'Title' ){ $('#quick-shop-product-actions .selector-wrapper:eq(0)').prepend(' '+ selectedProduct.options[0] +' '); } // Auto-select first available variant on page load. var found_one_in_stock = false; for (var i=0; i < selectedProduct.variants.length; i++) { var variant = selectedProduct.variants[i]; if(variant.available && found_one_in_stock == false) { found_one_in_stock = true; for (var j=0; j < variant.options.length; j++){ //$('.single-option-selector:eq('+ j +')').val(variant.options[j]).trigger('change'); } } } // swatch show_swatch(selectedProduct); ////// } else { // If product only has a single variant // Hide unnecessary variants container quickShopVariantsContainer.hide(); // swatch $('#show_swatch').html(''); // Build variants element var quickShopVariantElement = $(' ',{ 'id': ('quick-shop-variants-' + selectedProductID) , 'name': 'id'}); var quickShopVariantOptions = ''; for (var i=0; i < productVariantsCount; i++) { quickShopVariantOptions += ''+ productVariants[i].title +'' }; // Add variants element to page quickShopVariant