From 17da2c0c44ffcf62a5066c60945fb7f15f78e4a1 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 23 Jul 2013 11:49:16 +0100 Subject: [PATCH] Prevent breakage when moved to header by w3 total cache Closes #3412. --- assets/js/frontend/add-to-cart-variation.js | 8 +++++--- assets/js/frontend/add-to-cart-variation.min.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/js/frontend/add-to-cart-variation.js b/assets/js/frontend/add-to-cart-variation.js index 42808de6134..a0f0e3f2f10 100644 --- a/assets/js/frontend/add-to-cart-variation.js +++ b/assets/js/frontend/add-to-cart-variation.js @@ -399,7 +399,9 @@ return $form; }; - $('form.variations_form').wc_variation_form(); - $('form.variations_form .variations select').change(); + $(function() { + $('form.variations_form').wc_variation_form(); + $('form.variations_form .variations select').change(); + }); -})( jQuery, window, document ); +})( jQuery, window, document ); \ No newline at end of file diff --git a/assets/js/frontend/add-to-cart-variation.min.js b/assets/js/frontend/add-to-cart-variation.min.js index 193612f65c3..310f944659e 100644 --- a/assets/js/frontend/add-to-cart-variation.min.js +++ b/assets/js/frontend/add-to-cart-variation.min.js @@ -1,3 +1,3 @@ /*! * Variations Plugin - */(function(e,t,n,r){e.fn.wc_variation_form=function(){e.fn.wc_variation_form.find_matching_variations=function(t,n){var r=[];for(var i=0;i").html(o).text();o=o.replace(/'/g,"\\'");o=o.replace(/"/g,'\\"');current_attr_select.find('option[value="'+o+'"]').addClass("active")}else current_attr_select.find("option:gt(0)").addClass("active")}}current_attr_select.find("option:gt(0):not(.active)").remove()});$variation_form.trigger("woocommerce_update_variation_values")}).on("found_variation",function(t,n){var r=e(this),i=e(this).closest(".product"),s=i.find("div.images img:eq(0)"),o=i.find("div.images a.zoom:eq(0)"),u=s.attr("data-o_src"),a=s.attr("data-o_title"),f=o.attr("data-o_href"),l=n.image_src,c=n.image_link,h=n.image_title;r.find(".variations_button").show();r.find(".single_variation").html(n.price_html+n.availability_html);if(!u){u=s.attr("src")?s.attr("src"):"";s.attr("data-o_src",u)}if(!f){f=o.attr("href")?o.attr("href"):"";o.attr("data-o_href",f)}if(!a){a=s.attr("title")?s.attr("title"):"";s.attr("data-o_title",a)}if(l&&l.length>1){s.attr("src",l).attr("alt",h).attr("title",h);o.attr("href",c).attr("title",h)}else{s.attr("src",u).attr("alt",a).attr("title",a);o.attr("href",f).attr("title",a)}var p=r.find(".single_variation_wrap"),d=i.find(".product_meta").find(".sku"),v=i.find(".product_weight"),m=i.find(".product_dimensions");d.attr("data-o_sku")||d.attr("data-o_sku",d.text());v.attr("data-o_weight")||v.attr("data-o_weight",v.text());m.attr("data-o_dimensions")||m.attr("data-o_dimensions",m.text());n.sku?d.text(n.sku):d.text(d.attr("data-o_sku"));n.weight?v.text(n.weight):v.text(v.attr("data-o_weight"));n.dimensions?m.text(n.dimensions):m.text(m.attr("data-o_dimensions"));p.find(".quantity").show();!n.is_in_stock&&!n.backorders_allowed&&r.find(".variations_button").hide();n.min_qty?p.find("input[name=quantity]").attr("min",n.min_qty).val(n.min_qty):p.find("input[name=quantity]").removeAttr("min");n.max_qty?p.find("input[name=quantity]").attr("max",n.max_qty):p.find("input[name=quantity]").removeAttr("max");if(n.is_sold_individually=="yes"){p.find("input[name=quantity]").val("1");p.find(".quantity").hide()}p.slideDown("200").trigger("show_variation",[n])});$form.trigger("wc_variation_form");return $form};e("form.variations_form").wc_variation_form();e("form.variations_form .variations select").change()})(jQuery,window,document); \ No newline at end of file + */(function(e,t,n,r){e.fn.wc_variation_form=function(){e.fn.wc_variation_form.find_matching_variations=function(t,n){var r=[];for(var i=0;i").html(o).text();o=o.replace(/'/g,"\\'");o=o.replace(/"/g,'\\"');current_attr_select.find('option[value="'+o+'"]').addClass("active")}else current_attr_select.find("option:gt(0)").addClass("active")}}current_attr_select.find("option:gt(0):not(.active)").remove()});$variation_form.trigger("woocommerce_update_variation_values")}).on("found_variation",function(t,n){var r=e(this),i=e(this).closest(".product"),s=i.find("div.images img:eq(0)"),o=i.find("div.images a.zoom:eq(0)"),u=s.attr("data-o_src"),a=s.attr("data-o_title"),f=o.attr("data-o_href"),l=n.image_src,c=n.image_link,h=n.image_title;r.find(".variations_button").show();r.find(".single_variation").html(n.price_html+n.availability_html);if(!u){u=s.attr("src")?s.attr("src"):"";s.attr("data-o_src",u)}if(!f){f=o.attr("href")?o.attr("href"):"";o.attr("data-o_href",f)}if(!a){a=s.attr("title")?s.attr("title"):"";s.attr("data-o_title",a)}if(l&&l.length>1){s.attr("src",l).attr("alt",h).attr("title",h);o.attr("href",c).attr("title",h)}else{s.attr("src",u).attr("alt",a).attr("title",a);o.attr("href",f).attr("title",a)}var p=r.find(".single_variation_wrap"),d=i.find(".product_meta").find(".sku"),v=i.find(".product_weight"),m=i.find(".product_dimensions");d.attr("data-o_sku")||d.attr("data-o_sku",d.text());v.attr("data-o_weight")||v.attr("data-o_weight",v.text());m.attr("data-o_dimensions")||m.attr("data-o_dimensions",m.text());n.sku?d.text(n.sku):d.text(d.attr("data-o_sku"));n.weight?v.text(n.weight):v.text(v.attr("data-o_weight"));n.dimensions?m.text(n.dimensions):m.text(m.attr("data-o_dimensions"));p.find(".quantity").show();!n.is_in_stock&&!n.backorders_allowed&&r.find(".variations_button").hide();n.min_qty?p.find("input[name=quantity]").attr("min",n.min_qty).val(n.min_qty):p.find("input[name=quantity]").removeAttr("min");n.max_qty?p.find("input[name=quantity]").attr("max",n.max_qty):p.find("input[name=quantity]").removeAttr("max");if(n.is_sold_individually=="yes"){p.find("input[name=quantity]").val("1");p.find(".quantity").hide()}p.slideDown("200").trigger("show_variation",[n])});$form.trigger("wc_variation_form");return $form};e(function(){e("form.variations_form").wc_variation_form();e("form.variations_form .variations select").change()})})(jQuery,window,document); \ No newline at end of file