diff --git a/admin/writepanels/writepanel-product-type-variable.php b/admin/writepanels/writepanel-product-type-variable.php index 86c2fdb5ebe..5cfc71c173b 100644 --- a/admin/writepanels/writepanel-product-type-variable.php +++ b/admin/writepanels/writepanel-product-type-variable.php @@ -30,6 +30,7 @@ function variable_product_type_options() { ?>

+
+ + +

+ + ID, '_default_attributes', true )); + foreach ($attributes as $attribute) : + + // Only deal with attributes that are variations + if ( !$attribute['is_variation'] ) continue; + + // Get current value for variation (if set) + $variation_selected_value = (isset($default_attributes[sanitize_title($attribute['name'])])) ? $default_attributes[sanitize_title($attribute['name'])] : ''; + + // Name will be something like attribute_pa_color + echo ''; + + endforeach; + ?> +

+ @@ -675,9 +716,24 @@ function process_product_meta_variable( $post_id ) { endforeach; endif; + update_post_meta( $post_parent, 'price', $lowest_price ); update_post_meta( $post_parent, 'min_variation_price', $lowest_price ); update_post_meta( $post_parent, 'max_variation_price', $highest_price ); + + // Update default attribute options setting + $default_attributes = array(); + + foreach ($attributes as $attribute) : + if ( $attribute['is_variation'] ) : + $value = esc_attr(trim($_POST[ 'default_attribute_' . sanitize_title($attribute['name']) ])); + if ($value) : + $default_attributes[sanitize_title($attribute['name'])] = $value; + endif; + endif; + endforeach; + + update_post_meta( $post_parent, '_default_attributes', $default_attributes ); } add_action('woocommerce_process_product_meta_variable', 'process_product_meta_variable'); \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index 82a35763a09..608cd4fcb87 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -161,11 +161,11 @@ div.multi_select_products_wrapper-alt{float:right;} #grouped_product_options,#virtual_product_options,#simple_product_options{padding:12px;font-style:italic;color:#666;} #variable_product_options p.description{float:left;padding:0;margin:0;} #variable_product_options p.bulk_edit{background:#ececec;padding:6px;}#variable_product_options p.bulk_edit strong{margin:0 6px 0 0;} -.woocommerce_variation{background:#ececec;border:1px solid #ececec;margin:0 0 8px;}.woocommerce_variation p{margin:0 !important;}.woocommerce_variation p button{float:right;} -.woocommerce_variation table td{background:#fff;padding:6px 6px;vertical-align:middle;}.woocommerce_variation table td label{color:#999;font-size:10px;text-transform:uppercase;text-align:left;display:block;line-height:16px;} -.woocommerce_variation table td input{float:left;width:100%;} -.woocommerce_variation table td.upload_image{width:1%;white-space:nowrap;}.woocommerce_variation table td.upload_image img{float:none;margin-right:6px;vertical-align:middle;} -.woocommerce_variation table td.upload_image .button{margin:0;padding:4px 10px;width:auto;float:none;vertical-align:middle;} +.woocommerce_variation,.default_variation{background:#ececec;border:1px solid #ececec;margin:0 0 8px;}.woocommerce_variation p,.default_variation p{margin:0 !important;}.woocommerce_variation p button,.default_variation p button{float:right;} +.woocommerce_variation table td,.default_variation table td{background:#fff;padding:6px 6px;vertical-align:middle;}.woocommerce_variation table td label,.default_variation table td label{color:#999;font-size:10px;text-transform:uppercase;text-align:left;display:block;line-height:16px;} +.woocommerce_variation table td input,.default_variation table td input{float:left;width:100%;} +.woocommerce_variation table td.upload_image,.default_variation table td.upload_image{width:1%;white-space:nowrap;}.woocommerce_variation table td.upload_image img,.default_variation table td.upload_image img{float:none;margin-right:6px;vertical-align:middle;} +.woocommerce_variation table td.upload_image .button,.default_variation table td.upload_image .button{margin:0;padding:4px 10px;width:auto;float:none;vertical-align:middle;} .widefat .product-cat-placeholder{outline:1px dotted #A0C443;height:60px;background:#000;} .tips{cursor:help;text-decoration:none;} img.tips{padding:5px 0 0 0;} diff --git a/assets/css/admin.less b/assets/css/admin.less index a1866cb6c12..b4cc4557603 100644 --- a/assets/css/admin.less +++ b/assets/css/admin.less @@ -860,7 +860,7 @@ div.multi_select_products_wrapper-alt { } } } -.woocommerce_variation { +.woocommerce_variation, .default_variation { background: #ececec; border: 1px solid #ececec; margin: 0 0 8px; diff --git a/assets/js/woocommerce.js b/assets/js/woocommerce.js index 7283fbeacb2..a9f2783377e 100755 --- a/assets/js/woocommerce.js +++ b/assets/js/woocommerce.js @@ -394,6 +394,9 @@ jQuery(document).ready(function($) { if (variation) { $('form input[name=variation_id]').val(variation.variation_id); show_variation(variation); + } else { + // Nothing found - reset fields + $('.variations select').val(''); } } else { update_variation_values(matching_variations); @@ -407,13 +410,15 @@ jQuery(document).ready(function($) { $('.single_variation').text(''); check_variations(); $(this).blur(); - if($().uniform) $.uniform.update(); + if($.isFunction($.uniform.update)) { + $.uniform.update(); + } }).focus(function(){ check_variations( $(this).attr('name') ); - }); + }).change(); if (woocommerce_params.is_cart==1) { diff --git a/assets/js/woocommerce.min.js b/assets/js/woocommerce.min.js index f79fbfd49d7..891d050a8a8 100644 --- a/assets/js/woocommerce.min.js +++ b/assets/js/woocommerce.min.js @@ -1 +1 @@ -jQuery(document).ready(function(f){f(".add_to_cart_button").live("click",function(){var m=f(this);if(m.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){f(m).addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:f(m).attr("rel"),security:woocommerce_params.add_to_cart_nonce};f("body").trigger("adding_to_cart");f.post(woocommerce_params.ajax_url,n,function(o){n=f.parseJSON(o);if(n.error){alert(n.error);f(m).removeClass("loading");return}fragments=n;if(fragments){f.each(fragments,function(p,q){f(p).addClass("updating")})}f(".widget_shopping_cart, .shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});f(m).addClass("added");f(m).removeClass("loading");if(f(".widget_shopping_cart").size()>0){f(".widget_shopping_cart:eq(0)").load(window.location+" .widget_shopping_cart:eq(0) > *",function(){if(fragments){f.each(fragments,function(p,q){f(p).replaceWith(q)})}f(".widget_shopping_cart, .updating").css("opacity","1").unblock()})}else{if(fragments){f.each(fragments,function(p,q){f(p).replaceWith(q)})}f(".widget_shopping_cart, .updating").css("opacity","1").unblock()}f(".shop_table.cart").load(window.location+" .shop_table.cart:eq(0) > *",function(){f("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');f(".shop_table.cart").css("opacity","1").unblock()});f(".cart_totals").load(window.location+" .cart_totals:eq(0) > *",function(){f(".cart_totals").css("opacity","1").unblock()});f("body").trigger("added_to_cart")});return false}else{return true}});f("select.orderby").change(function(){f(this).closest("form").submit()});f("#rating").hide().before('

12345

');f("p.stars a").click(function(){f("#rating").val(f(this).text());f("p.stars a").removeClass("active");f(this).addClass("active");return false});var i=f(".price_slider_amount #min_price").val();var d=f(".price_slider_amount #max_price").val();if(woocommerce_params.min_price){current_min_price=woocommerce_params.min_price}else{current_min_price=i}if(woocommerce_params.max_price){current_max_price=woocommerce_params.max_price}else{current_max_price=d}current_min_price=parseInt(current_min_price);current_max_price=parseInt(current_max_price);f(".price_slider").slider({range:true,animate:true,min:i,max:d,values:[current_min_price,current_max_price],create:function(m,n){if(woocommerce_params.currency_pos=="left"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+current_min_price+" - "+woocommerce_params.currency_symbol+current_max_price)}else{if(woocommerce_params.currency_pos=="left_space"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+" "+current_min_price+" - "+woocommerce_params.currency_symbol+" "+current_max_price)}else{if(woocommerce_params.currency_pos=="right"){f(".price_slider_amount span").html(current_min_price+woocommerce_params.currency_symbol+" - "+current_max_price+woocommerce_params.currency_symbol)}else{if(woocommerce_params.currency_pos=="right_space"){f(".price_slider_amount span").html(current_min_price+" "+woocommerce_params.currency_symbol+" - "+current_max_price+" "+woocommerce_params.currency_symbol)}}}}f(".price_slider_amount #min_price").val(current_min_price);f(".price_slider_amount #max_price").val(current_max_price)},slide:function(m,n){if(woocommerce_params.currency_pos=="left"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+n.values[0]+" - "+woocommerce_params.currency_symbol+n.values[1])}else{if(woocommerce_params.currency_pos=="left_space"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+" "+n.values[0]+" - "+woocommerce_params.currency_symbol+" "+n.values[1])}else{if(woocommerce_params.currency_pos=="right"){f(".price_slider_amount span").html(n.values[0]+woocommerce_params.currency_symbol+" - "+n.values[1]+woocommerce_params.currency_symbol)}else{if(woocommerce_params.currency_pos=="right_space"){f(".price_slider_amount span").html(n.values[0]+" "+woocommerce_params.currency_symbol+" - "+n.values[1]+" "+woocommerce_params.currency_symbol)}}}}f("input#min_price").val(n.values[0]);f("input#max_price").val(n.values[1])}});f("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');f(".plus").live("click",function(){var m=parseInt(f(this).prev(".qty").val());if(!m||m==""||m=="NaN"){m=0}f(this).prev(".qty").val(m+1)});f(".minus").live("click",function(){var m=parseInt(f(this).next(".qty").val());if(m=="NaN"){m=1}if(m>1){f(this).next(".qty").val(m-1)}});var b=woocommerce_params.countries.replace(/"/g,'"');var j=f.parseJSON(b);f("select.country_to_state").change(function(){var r=f(this).val();var p=f("#"+f(this).attr("rel"));var s=f(p).attr("name");var o=f(p).attr("id");if(j[r]){var n="";var q=j[r];for(var m in q){n=n+'"}if(f(p).is("input")){f(p).replaceWith('");p=f("#"+f(this).attr("rel"))}f(p).append(n)}else{if(f(p).is("select")){f(p).replaceWith('');p=f("#"+f(this).attr("rel"))}}}).change();f("div.woocommerce_tabs .panel").hide();f("div.woocommerce_tabs ul.tabs li a").click(function(){var n=f(this).closest("div.woocommerce_tabs");var m=f(this).attr("href");f("ul.tabs li.active",n).removeClass("active");f("div.panel",n).hide();f("div"+m).show();f(this).parent().addClass("active");return false});f("div.woocommerce_tabs").each(function(){var m=window.location.hash;if(m.toLowerCase().indexOf("comment-")>=0){f("ul.tabs li.reviews_tab a",f(this)).click()}else{f("ul.tabs li:first a",f(this)).click()}});f(".shipping-calculator-form").hide();f(".shipping-calculator-button").click(function(){f(".shipping-calculator-form").slideToggle("slow",function(){})});f(".shipping-calculator-button").click(function(){return false});function a(q,p){var m=true;for(name in q){var o=q[name];var n=p[name];if(o.length!=0&&n.length!=0&&o!=n){m=false}}return m}function l(o){var q=[];for(var n=0;n1){f(m).attr("src",p);f(s).attr("href",n)}else{f(m).attr("src",r);f(s).attr("href",q)}f(".single_variation_wrap").slideDown("200")}function c(n){var m=true;var p={};f(".variations select").each(function(){if(n&&f(this).attr("name")==n){m=false;p[f(this).attr("name")]=""}else{if(f(this).val().length==0){m=false}value=f(this).val();value=value.replace('"',""");p[f(this).attr("name")]=value}});var q=l(p);if(m){var o=q.pop();if(o){f("form input[name=variation_id]").val(o.variation_id);g(o)}}else{h(q)}}f(".variations select").change(function(){f("form input[name=variation_id]").val("");f(".single_variation_wrap").hide();f(".single_variation").text("");c();f(this).blur();if(f().uniform){f.uniform.update()}}).focus(function(){c(f(this).attr("name"))});if(woocommerce_params.is_cart==1){f("select#shipping_method").live("change",function(){var n=f("#shipping_method").val();f("div.cart_totals").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var m={action:"woocommerce_update_shipping_method",security:woocommerce_params.update_shipping_method_nonce,shipping_method:n};f.post(woocommerce_params.ajax_url,m,function(o){f("div.cart_totals").replaceWith(o)})})}if(woocommerce_params.is_checkout==1){var k;function e(){var t=f("#shipping_method").val();var s=f("#billing_country").val();var q=f("#billing_state").val();var m=f("input#billing_postcode").val();if(f("#shiptobilling input").is(":checked")||f("#shiptobilling input").size()==0){var n=f("#billing_country").val();var p=f("#billing_state").val();var r=f("input#billing_postcode").val()}else{var n=f("#shipping_country").val();var p=f("#shipping_state").val();var r=f("input#shipping_postcode").val()}f("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var o={action:"woocommerce_update_order_review",security:woocommerce_params.update_order_review_nonce,shipping_method:t,country:s,state:q,postcode:m,s_country:n,s_state:p,s_postcode:r,post_data:f("form.checkout").serialize()};f.post(woocommerce_params.ajax_url,o,function(u){f("#order_methods, #order_review").remove();f("#order_review_heading").after(u);f("#order_review input[name=payment_method]:checked").click()})}f(function(){f("p.password").hide();f("input.show_password").change(function(){f("p.password").slideToggle()});f("div.shipping_address").hide();f("#shiptobilling input").change(function(){f("div.shipping_address").hide();if(!f(this).is(":checked")){f("div.shipping_address").slideDown()}}).change();if(woocommerce_params.option_guest_checkout=="yes"){f("div.create-account").hide();f("input#createaccount").change(function(){f("div.create-account").hide();if(f(this).is(":checked")){f("div.create-account").slideDown()}}).change()}f(".payment_methods input.input-radio").live("click",function(){f("div.payment_box").hide();if(f(this).is(":checked")){f("div.payment_box."+f(this).attr("ID")).slideDown()}});f("#order_review input[name=payment_method]:checked").click();f("form.login").hide();f("a.showlogin").click(function(){f("form.login").slideToggle();return false});f("#shipping_method").live("change",function(){clearTimeout(k);e()});f("input#billing_country, input#billing_state, #billing_postcode, input#shipping_country, input#shipping_state, #shipping_postcode").live("keydown",function(){clearTimeout(k);k=setTimeout("update_checkout()","1000")});f("select#billing_country, select#billing_state, select#shipping_country, select#shipping_state, #shiptobilling input, .update_totals_on_change").live("change",function(){clearTimeout(k);e()});e();f("form.checkout").submit(function(){var m=this;f(m).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});f.ajax({type:"POST",url:woocommerce_params.checkout_url,data:f(m).serialize(),success:function(o){f(".woocommerce_error, .woocommerce_message").remove();try{success=f.parseJSON(o);window.location=decodeURI(success.redirect)}catch(n){f(m).prepend(o);f(m).unblock();f("html, body").animate({scrollTop:(f("form.checkout").offset().top-100)},1000)}},dataType:"html"});return false})})}}); \ No newline at end of file +jQuery(document).ready(function(f){f(".add_to_cart_button").live("click",function(){var m=f(this);if(m.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){f(m).addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:f(m).attr("rel"),security:woocommerce_params.add_to_cart_nonce};f("body").trigger("adding_to_cart");f.post(woocommerce_params.ajax_url,n,function(o){n=f.parseJSON(o);if(n.error){alert(n.error);f(m).removeClass("loading");return}fragments=n;if(fragments){f.each(fragments,function(p,q){f(p).addClass("updating")})}f(".widget_shopping_cart, .shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});f(m).addClass("added");f(m).removeClass("loading");if(f(".widget_shopping_cart").size()>0){f(".widget_shopping_cart:eq(0)").load(window.location+" .widget_shopping_cart:eq(0) > *",function(){if(fragments){f.each(fragments,function(p,q){f(p).replaceWith(q)})}f(".widget_shopping_cart, .updating").css("opacity","1").unblock()})}else{if(fragments){f.each(fragments,function(p,q){f(p).replaceWith(q)})}f(".widget_shopping_cart, .updating").css("opacity","1").unblock()}f(".shop_table.cart").load(window.location+" .shop_table.cart:eq(0) > *",function(){f("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');f(".shop_table.cart").css("opacity","1").unblock()});f(".cart_totals").load(window.location+" .cart_totals:eq(0) > *",function(){f(".cart_totals").css("opacity","1").unblock()});f("body").trigger("added_to_cart")});return false}else{return true}});f("select.orderby").change(function(){f(this).closest("form").submit()});f("#rating").hide().before('

12345

');f("p.stars a").click(function(){f("#rating").val(f(this).text());f("p.stars a").removeClass("active");f(this).addClass("active");return false});var i=f(".price_slider_amount #min_price").val();var d=f(".price_slider_amount #max_price").val();if(woocommerce_params.min_price){current_min_price=woocommerce_params.min_price}else{current_min_price=i}if(woocommerce_params.max_price){current_max_price=woocommerce_params.max_price}else{current_max_price=d}current_min_price=parseInt(current_min_price);current_max_price=parseInt(current_max_price);f(".price_slider").slider({range:true,animate:true,min:i,max:d,values:[current_min_price,current_max_price],create:function(m,n){if(woocommerce_params.currency_pos=="left"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+current_min_price+" - "+woocommerce_params.currency_symbol+current_max_price)}else{if(woocommerce_params.currency_pos=="left_space"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+" "+current_min_price+" - "+woocommerce_params.currency_symbol+" "+current_max_price)}else{if(woocommerce_params.currency_pos=="right"){f(".price_slider_amount span").html(current_min_price+woocommerce_params.currency_symbol+" - "+current_max_price+woocommerce_params.currency_symbol)}else{if(woocommerce_params.currency_pos=="right_space"){f(".price_slider_amount span").html(current_min_price+" "+woocommerce_params.currency_symbol+" - "+current_max_price+" "+woocommerce_params.currency_symbol)}}}}f(".price_slider_amount #min_price").val(current_min_price);f(".price_slider_amount #max_price").val(current_max_price)},slide:function(m,n){if(woocommerce_params.currency_pos=="left"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+n.values[0]+" - "+woocommerce_params.currency_symbol+n.values[1])}else{if(woocommerce_params.currency_pos=="left_space"){f(".price_slider_amount span").html(woocommerce_params.currency_symbol+" "+n.values[0]+" - "+woocommerce_params.currency_symbol+" "+n.values[1])}else{if(woocommerce_params.currency_pos=="right"){f(".price_slider_amount span").html(n.values[0]+woocommerce_params.currency_symbol+" - "+n.values[1]+woocommerce_params.currency_symbol)}else{if(woocommerce_params.currency_pos=="right_space"){f(".price_slider_amount span").html(n.values[0]+" "+woocommerce_params.currency_symbol+" - "+n.values[1]+" "+woocommerce_params.currency_symbol)}}}}f("input#min_price").val(n.values[0]);f("input#max_price").val(n.values[1])}});f("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');f(".plus").live("click",function(){var m=parseInt(f(this).prev(".qty").val());if(!m||m==""||m=="NaN"){m=0}f(this).prev(".qty").val(m+1)});f(".minus").live("click",function(){var m=parseInt(f(this).next(".qty").val());if(m=="NaN"){m=1}if(m>1){f(this).next(".qty").val(m-1)}});var b=woocommerce_params.countries.replace(/"/g,'"');var j=f.parseJSON(b);f("select.country_to_state").change(function(){var r=f(this).val();var p=f("#"+f(this).attr("rel"));var s=f(p).attr("name");var o=f(p).attr("id");if(j[r]){var n="";var q=j[r];for(var m in q){n=n+'"}if(f(p).is("input")){f(p).replaceWith('");p=f("#"+f(this).attr("rel"))}f(p).append(n)}else{if(f(p).is("select")){f(p).replaceWith('');p=f("#"+f(this).attr("rel"))}}}).change();f("div.woocommerce_tabs .panel").hide();f("div.woocommerce_tabs ul.tabs li a").click(function(){var n=f(this).closest("div.woocommerce_tabs");var m=f(this).attr("href");f("ul.tabs li.active",n).removeClass("active");f("div.panel",n).hide();f("div"+m).show();f(this).parent().addClass("active");return false});f("div.woocommerce_tabs").each(function(){var m=window.location.hash;if(m.toLowerCase().indexOf("comment-")>=0){f("ul.tabs li.reviews_tab a",f(this)).click()}else{f("ul.tabs li:first a",f(this)).click()}});f(".shipping-calculator-form").hide();f(".shipping-calculator-button").click(function(){f(".shipping-calculator-form").slideToggle("slow",function(){})});f(".shipping-calculator-button").click(function(){return false});function a(q,p){var m=true;for(name in q){var o=q[name];var n=p[name];if(o.length!=0&&n.length!=0&&o!=n){m=false}}return m}function l(o){var q=[];for(var n=0;n1){f(m).attr("src",p);f(s).attr("href",n)}else{f(m).attr("src",r);f(s).attr("href",q)}f(".single_variation_wrap").slideDown("200")}function c(n){var m=true;var p={};f(".variations select").each(function(){if(n&&f(this).attr("name")==n){m=false;p[f(this).attr("name")]=""}else{if(f(this).val().length==0){m=false}value=f(this).val();value=value.replace('"',""");p[f(this).attr("name")]=value}});var q=l(p);if(m){var o=q.pop();if(o){f("form input[name=variation_id]").val(o.variation_id);g(o)}else{f(".variations select").val("")}}else{h(q)}}f(".variations select").change(function(){f("form input[name=variation_id]").val("");f(".single_variation_wrap").hide();f(".single_variation").text("");c();f(this).blur();if(f.isFunction(f.uniform.update)){f.uniform.update()}}).focus(function(){c(f(this).attr("name"))}).change();if(woocommerce_params.is_cart==1){f("select#shipping_method").live("change",function(){var n=f("#shipping_method").val();f("div.cart_totals").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var m={action:"woocommerce_update_shipping_method",security:woocommerce_params.update_shipping_method_nonce,shipping_method:n};f.post(woocommerce_params.ajax_url,m,function(o){f("div.cart_totals").replaceWith(o)})})}if(woocommerce_params.is_checkout==1){var k;function e(){var t=f("#shipping_method").val();var s=f("#billing_country").val();var q=f("#billing_state").val();var m=f("input#billing_postcode").val();if(f("#shiptobilling input").is(":checked")||f("#shiptobilling input").size()==0){var n=f("#billing_country").val();var p=f("#billing_state").val();var r=f("input#billing_postcode").val()}else{var n=f("#shipping_country").val();var p=f("#shipping_state").val();var r=f("input#shipping_postcode").val()}f("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var o={action:"woocommerce_update_order_review",security:woocommerce_params.update_order_review_nonce,shipping_method:t,country:s,state:q,postcode:m,s_country:n,s_state:p,s_postcode:r,post_data:f("form.checkout").serialize()};f.post(woocommerce_params.ajax_url,o,function(u){f("#order_methods, #order_review").remove();f("#order_review_heading").after(u);f("#order_review input[name=payment_method]:checked").click()})}f(function(){f("p.password").hide();f("input.show_password").change(function(){f("p.password").slideToggle()});f("div.shipping_address").hide();f("#shiptobilling input").change(function(){f("div.shipping_address").hide();if(!f(this).is(":checked")){f("div.shipping_address").slideDown()}}).change();if(woocommerce_params.option_guest_checkout=="yes"){f("div.create-account").hide();f("input#createaccount").change(function(){f("div.create-account").hide();if(f(this).is(":checked")){f("div.create-account").slideDown()}}).change()}f(".payment_methods input.input-radio").live("click",function(){f("div.payment_box").hide();if(f(this).is(":checked")){f("div.payment_box."+f(this).attr("ID")).slideDown()}});f("#order_review input[name=payment_method]:checked").click();f("form.login").hide();f("a.showlogin").click(function(){f("form.login").slideToggle();return false});f("#shipping_method").live("change",function(){clearTimeout(k);e()});f("input#billing_country, input#billing_state, #billing_postcode, input#shipping_country, input#shipping_state, #shipping_postcode").live("keydown",function(){clearTimeout(k);k=setTimeout("update_checkout()","1000")});f("select#billing_country, select#billing_state, select#shipping_country, select#shipping_state, #shiptobilling input, .update_totals_on_change").live("change",function(){clearTimeout(k);e()});e();f("form.checkout").submit(function(){var m=this;f(m).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});f.ajax({type:"POST",url:woocommerce_params.checkout_url,data:f(m).serialize(),success:function(o){f(".woocommerce_error, .woocommerce_message").remove();try{success=f.parseJSON(o);window.location=decodeURI(success.redirect)}catch(n){f(m).prepend(o);f(m).unblock();f("html, body").animate({scrollTop:(f("form.checkout").offset().top-100)},1000)}},dataType:"html"});return false})})}}); \ No newline at end of file diff --git a/readme.txt b/readme.txt index 1b13be98da8..15a3bd69e11 100644 --- a/readme.txt +++ b/readme.txt @@ -95,6 +95,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo * Best sellers widget based on new total_sales field * Ability to exclude product ids * Option for the recipient of order/stock emails +* Options to define default attribute selections in variations * Edit category - image fix * Order Complete email heading fix * 100% discount when price excludes tax logic fix diff --git a/woocommerce_template_functions.php b/woocommerce_template_functions.php index baff37ceaae..f142ac07cef 100644 --- a/woocommerce_template_functions.php +++ b/woocommerce_template_functions.php @@ -352,6 +352,7 @@ if (!function_exists('woocommerce_variable_add_to_cart')) { global $post, $_product, $woocommerce; $attributes = $_product->get_available_attribute_variations(); + $default_attributes = (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true )); // Put available variations into an array and put in a Javascript variable (JSON encoded) $available_variations = array(); @@ -402,6 +403,7 @@ if (!function_exists('woocommerce_variable_add_to_cart')) { 'ASC'); @@ -409,11 +411,11 @@ if (!function_exists('woocommerce_variable_add_to_cart')) { foreach ($terms as $term) : if (!in_array($term->slug, $options)) continue; - echo ''; + echo ''; endforeach; else : foreach ($options as $option) : - echo ''; + echo ''; endforeach; endif; ?>