From eb90b0ed1084ec630abde5fcd475cad1538faf5c Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Fri, 12 Oct 2012 15:33:46 +0200 Subject: [PATCH] Allow multiple select and actually send the resend order emails --- .../writepanels/writepanel-order_data.php | 42 +++++++++++++++---- assets/js/admin/write-panels.js | 2 + assets/js/admin/write-panels.min.js | 2 +- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/admin/post-types/writepanels/writepanel-order_data.php b/admin/post-types/writepanels/writepanel-order_data.php index d0431884000..cd0f2bc1b92 100644 --- a/admin/post-types/writepanels/writepanel-order_data.php +++ b/admin/post-types/writepanels/writepanel-order_data.php @@ -476,18 +476,24 @@ function woocommerce_order_actions_meta_box($post) { global $woocommerce; $mailer = $woocommerce->mailer(); - $available_emails = array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ); + $available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ) ); + $mails = $mailer->get_emails(); - foreach ( $mailer->get_emails() as $mail ) { - if ( in_array( $mail->id, $available_emails ) ) { - echo '
'; + if ( ! empty( $mails ) ) { + foreach ( $mails as $mail ) { + if ( in_array( $mail->id, $available_emails ) ) { + echo '
'; + } } + + ?> +

+ + +

+ -

- - -

@@ -959,6 +965,26 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) { do_action( 'woocommerce_after__customer_invoice', $order ); + elseif (isset($_POST['order_email']) && $_POST['order_email']) : + + do_action( 'woocommerce_before_resend_order_emails', $order ); + + $mailer = $woocommerce->mailer(); + + $available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ) ); + $resend_emails = array_intersect( $available_emails, $_POST['order_email'] ); + $mails = $mailer->get_emails(); + + if ( ! empty( $mails ) ) { + foreach ( $mails as $mail ) { + if ( in_array( $mail->id, $resend_emails ) ) { + $mail->trigger( $order->id ); + } + } + } + + do_action( 'woocommerce_after_resend_order_emails', $order ); + endif; delete_transient( 'woocommerce_processing_order_count' ); diff --git a/assets/js/admin/write-panels.js b/assets/js/admin/write-panels.js index f4ef7e83fcd..0cfc5b4ad4c 100644 --- a/assets/js/admin/write-panels.js +++ b/assets/js/admin/write-panels.js @@ -32,6 +32,8 @@ jQuery( function($){ }); $('#order-emails a.hide-order-emails').click(function () { + $('input[name="order_email[]"]').each( function() { $(this).attr('checked', false) } ); + if ($('#order-emails-select').is(":visible")) { $('#order-emails-select').slideUp('fast'); $('#order-emails a.show-order-emails').show(); diff --git a/assets/js/admin/write-panels.min.js b/assets/js/admin/write-panels.min.js index fb3c11d1ed7..e0ba9e67f13 100644 --- a/assets/js/admin/write-panels.min.js +++ b/assets/js/admin/write-panels.min.js @@ -1 +1 @@ -jQuery(function(e){function r(){e(".woocommerce_attributes .woocommerce_attribute").each(function(t,n){e(".attribute_position",n).val(parseInt(e(n).index(".woocommerce_attributes .woocommerce_attribute")))})}e("#upsell_product_data").bind("keypress",function(e){if(e.keyCode==13)return!1});e(".type_box").appendTo("#woocommerce-product-data h3.hndle span");e(function(){e("#woocommerce-product-data h3.hndle").unbind("click.postboxes");jQuery("#woocommerce-product-data").on("click","h3.hndle",function(t){if(e(t.target).filter("input, option, label, select").length)return;e("#woocommerce-product-data").toggleClass("closed")})});e("#order-emails a.show-order-emails").click(function(){if(e("#order-emails-select").is(":hidden")){e("#order-emails-select").slideDown("fast");e(this).hide()}return!1});e("#order-emails a.hide-order-emails").click(function(){if(e("#order-emails-select").is(":visible")){e("#order-emails-select").slideUp("fast");e("#order-emails a.show-order-emails").show()}return!1});e("#catalog-visibility .edit-catalog-visibility").click(function(){if(e("#catalog-visibility-select").is(":hidden")){e("#catalog-visibility-select").slideDown("fast");e(this).hide()}return!1});e("#catalog-visibility .save-post-visibility").click(function(){e("#catalog-visibility-select").slideUp("fast");e("#catalog-visibility .edit-catalog-visibility").show();var t=e("input[name=_visibility]:checked").val(),n=e("input[name=_visibility]:checked").attr("data-label");if(e("input[name=_featured]").is(":checked")){n=n+", "+woocommerce_writepanel_params.featured_label;e("input[name=_featured]").attr("checked","checked")}e("#catalog-visibility-display").text(n);return!1});e("#catalog-visibility .cancel-post-visibility").click(function(){e("#catalog-visibility-select").slideUp("fast");e("#catalog-visibility .edit-catalog-visibility").show();var t=e("#current_visibilty").val(),n=e("#current_featured").val();e("input[name=_visibility]").removeAttr("checked");e("input[name=_visibility][value="+t+"]").attr("checked","checked");var r=e("input[name=_visibility]:checked").attr("data-label");if(n=="yes"){r=r+", "+woocommerce_writepanel_params.featured_label;e("input[name=_featured]").attr("checked","checked")}else e("input[name=_featured]").removeAttr("checked");e("#catalog-visibility-display").text(r);return!1});e("ul.wc-tabs").show();e("div.panel-wrap").each(function(){e("div.panel:not(div.panel:first)",this).hide()});e("ul.wc-tabs a").click(function(){var t=e(this).closest("div.panel-wrap");e("ul.wc-tabs li",t).removeClass("active");e(this).parent().addClass("active");e("div.panel",t).hide();e(e(this).attr("href")).show();return!1});jQuery("select.chosen_select").chosen();jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"});jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_writepanel_params.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_writepanel_params.search_products_nonce}},function(t){var n={};e.each(t,function(e,t){n[e]=t});return n});jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_writepanel_params.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products_and_variations",security:woocommerce_writepanel_params.search_products_nonce}},function(t){var n={};e.each(t,function(e,t){n[e]=t});return n});jQuery("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""});e("a.edit_address").click(function(t){e(this).hide();e(this).closest(".order_data").find("div.address").hide();e(this).closest(".order_data").find("div.edit_address").show();t.preventDefault()});e("#order_items_list .remove_row").live("click",function(){var t=confirm(woocommerce_writepanel_params.remove_item_notice);if(t){e(this).closest("tr.item").hide();e("input",e(this).closest("tr.item")).val("")}return!1});e("#order_items_list").on("init_row","tr.item",function(){var t=e(this),n=t.find("input.quantity"),r=n.val(),i=t.find("input.line_subtotal").val(),s=t.find("input.line_total").val(),o=t.find("input.line_tax").val(),u=t.find("input.line_subtotal_tax").val();if(r){unit_subtotal=accounting.toFixed(i/r,2);unit_subtotal_tax=accounting.toFixed(u/r,2);unit_total=accounting.toFixed(s/r,2);unit_total_tax=accounting.toFixed(o/r,2)}else unit_subtotal=unit_subtotal_tax=unit_total=unit_total_tax=0;n.attr("data-o_qty",r);t.attr("data-unit_subtotal",unit_subtotal);t.attr("data-unit_subtotal_tax",unit_subtotal_tax);t.attr("data-unit_total",unit_total);t.attr("data-unit_total_tax",unit_total_tax)});e("#order_items_list tr.item").each(function(){e(this).trigger("init_row")});e("#order_items_list").on("change","input.quantity",function(){var t=e(this).closest("tr.item"),n=e(this).val(),r=t.attr("data-unit_subtotal"),i=t.attr("data-unit_subtotal_tax"),s=t.attr("data-unit_total"),o=t.attr("data-unit_total_tax"),u=e(this).attr("data-o_qty"),a=accounting.formatNumber(r*n,2,""),f=accounting.formatNumber(i*n,2,""),l=accounting.formatNumber(s*n,2,""),c=accounting.formatNumber(o*n,2,"");t.find("input.line_subtotal").val(a);t.find("input.line_total").val(l);t.find("input.line_subtotal_tax").val(f);t.find("input.line_tax").val(c)});e("#order_items_list").on("change","input.line_subtotal",function(){var t=e(this).closest("tr.item"),n=t.find("input.quantity"),r=n.val(),i=r?accounting.toFixed(e(this).val()/r,2):0;t.attr("data-unit_subtotal",i)});e("#order_items_list").on("change","input.line_total",function(){var t=e(this).closest("tr.item"),n=t.find("input.quantity"),r=n.val(),i=r?accounting.toFixed(e(this).val()/r,2):0;t.attr("data-unit_total",i)});e("#order_items_list").on("change","input.line_subtotal_tax",function(){var t=e(this).closest("tr.item"),n=t.find("input.quantity"),r=n.val(),i=r?accounting.toFixed(e(this).val()/r,2):0;t.attr("data-unit_subtotal_tax",i)});e("#order_items_list").on("change","input.line_tax",function(){var t=e(this).closest("tr.item"),n=t.find("input.quantity"),r=n.val(),i=r?accounting.toFixed(e(this).val()/r,2):0;t.attr("data-unit_total_tax",i)});e("#woocommerce-order-totals").on("change","#_order_tax, #_order_shipping_tax, #_cart_discount, #_order_discount",function(){var t=e(this),n=t.closest(".totals").find("input"),r=0;n.each(function(){r+=parseFloat(e(this).val())});var i=accounting.formatMoney(r,{symbol:woocommerce_writepanel_params.currency_format_symbol,decimal:woocommerce_writepanel_params.currency_format_decimal_sep,thousand:woocommerce_writepanel_params.currency_format_thousand_sep,precision:woocommerce_writepanel_params.currency_format_num_decimals,format:woocommerce_writepanel_params.currency_format});t.closest(".totals_group").find("span.inline_total").text(i)});e("span.inline_total").closest(".totals_group").find("input").change();e("button.calc_line_taxes").live("click",function(){e(".woocommerce_order_items_wrapper").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=confirm(woocommerce_writepanel_params.calc_line_taxes);if(t){var n=e("#order_items_list tr.item"),r=e("#_shipping_country").val();if(r)var i=e("#_shipping_state").val(),s=e("#_shipping_postcode").val(),o=e("#_shipping_city").val();else{r=e("#_billing_country").val();var i=e("#_billing_state").val(),s=e("#_billing_postcode").val(),o=e("#_billing_city").val()}n.each(function(t){var u=e(this),a={action:"woocommerce_calc_line_taxes",item_id:u.find("input.item_id").val(),line_subtotal:u.find("input.line_subtotal").val(),line_total:u.find("input.line_total").val(),tax_class:u.find("select.tax_class").val(),country:r,state:i,postcode:s,city:o,security:woocommerce_writepanel_params.calc_totals_nonce};e.post(woocommerce_writepanel_params.ajax_url,a,function(r){result=jQuery.parseJSON(r);u.find("input.line_subtotal_tax").val(result.line_subtotal_tax).change();u.find("input.line_tax").val(result.line_tax).change();t==n.size()-1&&e(".woocommerce_order_items_wrapper").unblock()})})}else e(".woocommerce_order_items_wrapper").unblock();return!1}).hover(function(){e("#order_items_list input.line_subtotal_tax, #order_items_list input.line_tax").css("background-color","#d8c8d2")},function(){e("#order_items_list input.line_subtotal_tax, #order_items_list input.line_tax").css("background-color","")});e("button.calc_totals").live("click",function(){e("#woocommerce-order-totals").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=confirm(woocommerce_writepanel_params.calc_totals);if(t){var n=0,r=0,i=0,s=0,o=0,u=accounting.unformat(e("#_order_shipping").val()),a=accounting.unformat(e("#_order_shipping_tax").val()),f=accounting.unformat(e("#_order_discount").val());u||(u=0);a||(a=0);f||(f=0);e("#order_items_list tr.item").each(function(){var t=accounting.unformat(e(this).find("input.line_subtotal").val()),s=accounting.unformat(e(this).find("input.line_subtotal_tax").val()),u=accounting.unformat(e(this).find("input.line_total").val()),a=accounting.unformat(e(this).find("input.line_tax").val());t||(t=0);s||(s=0);u||(u=0);a||(a=0);n+=t;r+=s;i+=u;woocommerce_writepanel_params.round_at_subtotal=="no"&&(a=accounting.toFixed(a,2));o+=a});woocommerce_writepanel_params.round_at_subtotal=="yes"&&(o=accounting.toFixed(o,2));var s=n+r-(i+o);s<0&&(s=0);s=accounting.toFixed(s,2);var l=i+o+u+a-f;l=accounting.toFixed(l,2);o=accounting.toFixed(o,2);e("#_cart_discount").val(s);e("#_order_tax").val(o);e("#_order_total").val(l);e("#tax_rows").empty();e("#woocommerce-order-totals").unblock()}else e("#woocommerce-order-totals").unblock();return!1}).hover(function(){e("#woocommerce-order-totals .calculated").css("background-color","#d8c8d2")},function(){e("#woocommerce-order-totals .calculated").css("background-color","")});e("button.add_shop_order_item").click(function(){var t=e("select#add_item_id").val();if(t){count=t.length;e("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var n=e("table.woocommerce_order_items tbody tr.item").size();e.each(t,function(t,r){var i={action:"woocommerce_add_order_item",item_to_add:r,index:n,security:woocommerce_writepanel_params.add_order_item_nonce};e.post(woocommerce_writepanel_params.ajax_url,i,function(t){e("table.woocommerce_order_items tbody#order_items_list").append(t);if(!--count){e("select#add_item_id, #add_item_id_chzn .chzn-choices").css("border-color","").val("");jQuery(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200});e("select#add_item_id").trigger("liszt:updated");e("table.woocommerce_order_items").unblock()}e("#order_items_list tr.new_row").trigger("init_row").removeClass("new_row")});n++})}else e("select#add_item_id, #add_item_id_chzn .chzn-choices").css("border-color","red")});e("button.add_meta").live("click",function(){var t=e(this).closest("tr.item").attr("rel");e(this).closest("table.meta").find(".meta_items").append('');return!1});e("button.remove_meta").live("click",function(){var t=confirm("Remove this meta key?");t&&e(this).closest("tr").remove();return!1});e("button.load_customer_billing").live("click",function(){var t=confirm(woocommerce_writepanel_params.load_billing);if(t){var n=e("#customer_user").val();if(!n){alert(woocommerce_writepanel_params.no_customer_selected);return!1}var r={user_id:n,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_writepanel_params.get_customer_details_nonce};e(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});e.ajax({url:woocommerce_writepanel_params.ajax_url,data:r,type:"POST",success:function(t){var n=jQuery.parseJSON(t);if(n){e("input#_billing_first_name").val(n.billing_first_name);e("input#_billing_last_name").val(n.billing_last_name);e("input#_billing_company").val(n.billing_company);e("input#_billing_address_1").val(n.billing_address_1);e("input#_billing_address_2").val(n.billing_address_2);e("input#_billing_city").val(n.billing_city);e("input#_billing_postcode").val(n.billing_postcode);e("#_billing_country").val(n.billing_country);e("input#_billing_state").val(n.billing_state);e("input#_billing_email").val(n.billing_email);e("input#_billing_phone").val(n.billing_phone)}e(".edit_address").unblock()}})}return!1});e("button.load_customer_shipping").live("click",function(){var t=confirm(woocommerce_writepanel_params.load_shipping);if(t){var n=e("#customer_user").val();if(!n){alert(woocommerce_writepanel_params.no_customer_selected);return!1}var r={user_id:n,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_writepanel_params.get_customer_details_nonce};e(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});e.ajax({url:woocommerce_writepanel_params.ajax_url,data:r,type:"POST",success:function(t){var n=jQuery.parseJSON(t);if(n){e("input#_shipping_first_name").val(n.shipping_first_name);e("input#_shipping_last_name").val(n.shipping_last_name);e("input#_shipping_company").val(n.shipping_company);e("input#_shipping_address_1").val(n.shipping_address_1);e("input#_shipping_address_2").val(n.shipping_address_2);e("input#_shipping_city").val(n.shipping_city);e("input#_shipping_postcode").val(n.shipping_postcode);e("#_shipping_country").val(n.shipping_country);e("input#_shipping_state").val(n.shipping_state)}e(".edit_address").unblock()}})}return!1});e("button.billing-same-as-shipping").live("click",function(){var t=confirm(woocommerce_writepanel_params.copy_billing);if(t){e("input#_shipping_first_name").val(e("input#_billing_first_name").val());e("input#_shipping_last_name").val(e("input#_billing_last_name").val());e("input#_shipping_company").val(e("input#_billing_company").val());e("input#_shipping_address_1").val(e("input#_billing_address_1").val());e("input#_shipping_address_2").val(e("input#_billing_address_2").val());e("input#_shipping_city").val(e("input#_billing_city").val());e("input#_shipping_postcode").val(e("input#_billing_postcode").val());e("#_shipping_country").val(e("#_billing_country").val());e("input#_shipping_state").val(e("input#_billing_state").val())}return!1});e("a.add_tax_row").live("click",function(){var t=e("#tax_rows .tax_row").size();e("#tax_rows").append('

×
');return!1});e("a.delete_tax_row").live("click",function(){$tax_row=e(this).closest(".tax_row");$tax_row.find("input").val("");$tax_row.hide();return!1});e("select#product-type").change(function(){var t=e(this).val();e(".hide_if_grouped, .hide_if_external").show();e(".show_if_simple, .show_if_variable, .show_if_grouped, .show_if_external").hide();if(t=="simple"){e(".show_if_simple").show();e("input#_manage_stock").change()}else if(t=="variable"){e(".show_if_variable").show();e("input#_manage_stock").change();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change()}else if(t=="grouped"){e(".show_if_grouped").show();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change();e(".hide_if_grouped").hide()}else if(t=="external"){e(".show_if_external").show();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change();e(".hide_if_external").hide()}e("ul.wc-tabs li:visible").eq(0).find("a").click();e("body").trigger("woocommerce-product-type-change",t,e(this))}).change();e("input#_downloadable").change(function(){e(".show_if_downloadable").hide();e("input#_downloadable").is(":checked")&&e(".show_if_downloadable").show();e(".downloads_tab").is(".active")&&e("ul.wc-tabs li:visible").eq(0).find("a").click()}).change();e("input#_virtual").change(function(){e(".show_if_virtual").hide();e(".hide_if_virtual").show();if(e("input#_virtual").is(":checked")){e(".show_if_virtual").show();e(".hide_if_virtual").hide()}}).change();e(".sale_price_dates_fields").each(function(){var t=e(this),n=!1,r=t.closest("div, table");t.find("input").each(function(){e(this).val()!=""&&(n=!0)});if(n){r.find(".sale_schedule").hide();r.find(".sale_price_dates_fields").show()}else{r.find(".sale_schedule").show();r.find(".sale_price_dates_fields").hide()}});e("#woocommerce-product-data").on("click",".sale_schedule",function(){var t=e(this).closest("div, table");e(this).hide();t.find(".cancel_sale_schedule").show();t.find(".sale_price_dates_fields").show();return!1});e("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var t=e(this).closest("div, table");e(this).hide();t.find(".sale_schedule").show();t.find(".sale_price_dates_fields").hide();t.find(".sale_price_dates_fields").find("input").val("");return!1});e("input#_manage_stock").change(function(){e(this).is(":checked")?e("div.stock_fields").show():e("div.stock_fields").hide()}).change();var t=e(".sale_price_dates_fields input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:!0,onSelect:function(n){var r=this.id=="_sale_price_dates_from"?"minDate":"maxDate",i=e(this).data("datepicker"),s=e.datepicker.parseDate(i.settings.dateFormat||e.datepicker._defaults.dateFormat,n,i.settings);t.not(this).datepicker("option",r,s)}});e(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:!0});e(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0});jQuery(".expand_all").click(function(){jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").show();return!1});jQuery(".close_all").click(function(){jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").hide();return!1});jQuery(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(t){if(e(t.target).filter(":input, option").length)return;jQuery(this).next(".wc-metabox-content").toggle()});jQuery(".wc-metabox.closed").each(function(){jQuery(this).find(".wc-metabox-content").hide()});e(".woocommerce_attributes select.multiselect").chosen();var n=e(".woocommerce_attributes").find(".woocommerce_attribute").get();n.sort(function(t,n){var r=parseInt(e(t).attr("rel")),i=parseInt(e(n).attr("rel"));return ri?1:0});e(n).each(function(t,n){e(".woocommerce_attributes").append(n)});e("button.add_attribute").on("click",function(){var t=e(".woocommerce_attributes .woocommerce_attribute").size(),n=e("select.attribute_taxonomy").val();if(!n){var i=e("select#product-type").val();i!="variable"?enable_variation='style="display:none;"':enable_variation="";e(".woocommerce_attributes").append('

")}else{var s=e(".woocommerce_attributes .woocommerce_attribute."+n);e(".woocommerce_attributes").append(e(s));e(s).show().find(".woocommerce_attribute_data").show();r()}e("select.attribute_taxonomy").val("")});e(".woocommerce_attributes").on("blur","input.attribute_name",function(){e(this).closest(".woocommerce_attribute").find("strong.attribute_name").text(e(this).val())});e(".woocommerce_attributes").on("click","button.select_all_attributes",function(){e(this).closest("td").find("select option").attr("selected","selected");e(this).closest("td").find("select").trigger("liszt:updated");return!1});e(".woocommerce_attributes").on("click","button.select_no_attributes",function(){e(this).closest("td").find("select option").removeAttr("selected");e(this).closest("td").find("select").trigger("liszt:updated");return!1});e(".woocommerce_attributes").on("click","button.remove_row",function(){var t=confirm(woocommerce_writepanel_params.remove_attribute);if(t){var n=e(this).parent().parent();if(n.is(".taxonomy")){n.find("select, input[type=text]").val("");n.hide()}else{n.find("select, input[type=text]").val("");n.hide();r()}}return!1});e(".woocommerce_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style");r()}});e(".woocommerce_attributes").on("click","button.add_new_attribute",function(){e(".woocommerce_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=e(this).attr("data-attribute"),n=e(this).closest(".woocommerce_attribute_data"),r=prompt(woocommerce_writepanel_params.new_attribute_prompt);if(r){var i={action:"woocommerce_add_new_attribute",taxonomy:t,term:r,security:woocommerce_writepanel_params.add_attribute_nonce};e.post(woocommerce_writepanel_params.ajax_url,i,function(t){result=jQuery.parseJSON(t);if(result.error)alert(result.error);else if(result.slug){n.find("select.attribute_values").append('");n.find("select.attribute_values").trigger("liszt:updated")}e(".woocommerce_attributes").unblock()})}else e(".woocommerce_attributes").unblock();return!1});var i;window.send_to_editor_default=window.send_to_editor;jQuery(".upload_file_button").live("click",function(){i=jQuery(this).parent().find(".file_paths");formfield=jQuery(i).attr("name");window.send_to_editor=window.send_to_download_url;tb_show("","media-upload.php?post_id="+woocommerce_writepanel_params.post_id+"&type=downloadable_product&from=wc01&TB_iframe=true");return!1});window.send_to_download_url=function(e){file_url=jQuery(e).attr("href");file_url&&jQuery(i).val(jQuery(i).val()?jQuery(i).val()+"\n"+file_url:file_url);tb_remove();window.send_to_editor=window.send_to_editor_default}});(function(e,t){function n(e){return!!(""===e||e&&e.charCodeAt&&e.substr)}function r(e){return c?c(e):"[object Array]"===h.call(e)}function i(e){return"[object Object]"===h.call(e)}function s(e,t){var n,e=e||{},t=t||{};for(n in t)t.hasOwnProperty(n)&&null==e[n]&&(e[n]=t[n]);return e}function o(e,t,n){var r=[],i,s;if(!e)return r;if(l&&e.map===l)return e.map(t,n);for(i=0,s=e.length;ie?"-":"",m=parseInt(d(Math.abs(e||0),c),10)+"",g=3e?g.neg:g.zero).replace("%s",d.symbol).replace("%v",v(Math.abs(e),u(d.precision),d.thousand,d.decimal))};f.formatColumn=function(e,t,l,c,h,d){if(!e)return[];var m=s(i(t)?t:{symbol:t,precision:l,thousand:c,decimal:h,format:d},f.settings.currency),g=a(m.format),y=g.pos.indexOf("%s")e?g.neg:g.zero).replace("%s",m.symbol).replace("%v",v(Math.abs(e),u(m.precision),m.thousand,m.decimal));e.length>b&&(b=e.length);return e});return o(e,function(e){return n(e)&&e.length');return!1});e("button.remove_meta").live("click",function(){var t=confirm("Remove this meta key?");t&&e(this).closest("tr").remove();return!1});e("button.load_customer_billing").live("click",function(){var t=confirm(woocommerce_writepanel_params.load_billing);if(t){var n=e("#customer_user").val();if(!n){alert(woocommerce_writepanel_params.no_customer_selected);return!1}var r={user_id:n,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_writepanel_params.get_customer_details_nonce};e(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});e.ajax({url:woocommerce_writepanel_params.ajax_url,data:r,type:"POST",success:function(t){var n=jQuery.parseJSON(t);if(n){e("input#_billing_first_name").val(n.billing_first_name);e("input#_billing_last_name").val(n.billing_last_name);e("input#_billing_company").val(n.billing_company);e("input#_billing_address_1").val(n.billing_address_1);e("input#_billing_address_2").val(n.billing_address_2);e("input#_billing_city").val(n.billing_city);e("input#_billing_postcode").val(n.billing_postcode);e("#_billing_country").val(n.billing_country);e("input#_billing_state").val(n.billing_state);e("input#_billing_email").val(n.billing_email);e("input#_billing_phone").val(n.billing_phone)}e(".edit_address").unblock()}})}return!1});e("button.load_customer_shipping").live("click",function(){var t=confirm(woocommerce_writepanel_params.load_shipping);if(t){var n=e("#customer_user").val();if(!n){alert(woocommerce_writepanel_params.no_customer_selected);return!1}var r={user_id:n,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_writepanel_params.get_customer_details_nonce};e(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});e.ajax({url:woocommerce_writepanel_params.ajax_url,data:r,type:"POST",success:function(t){var n=jQuery.parseJSON(t);if(n){e("input#_shipping_first_name").val(n.shipping_first_name);e("input#_shipping_last_name").val(n.shipping_last_name);e("input#_shipping_company").val(n.shipping_company);e("input#_shipping_address_1").val(n.shipping_address_1);e("input#_shipping_address_2").val(n.shipping_address_2);e("input#_shipping_city").val(n.shipping_city);e("input#_shipping_postcode").val(n.shipping_postcode);e("#_shipping_country").val(n.shipping_country);e("input#_shipping_state").val(n.shipping_state)}e(".edit_address").unblock()}})}return!1});e("button.billing-same-as-shipping").live("click",function(){var t=confirm(woocommerce_writepanel_params.copy_billing);if(t){e("input#_shipping_first_name").val(e("input#_billing_first_name").val());e("input#_shipping_last_name").val(e("input#_billing_last_name").val());e("input#_shipping_company").val(e("input#_billing_company").val());e("input#_shipping_address_1").val(e("input#_billing_address_1").val());e("input#_shipping_address_2").val(e("input#_billing_address_2").val());e("input#_shipping_city").val(e("input#_billing_city").val());e("input#_shipping_postcode").val(e("input#_billing_postcode").val());e("#_shipping_country").val(e("#_billing_country").val());e("input#_shipping_state").val(e("input#_billing_state").val())}return!1});e("a.add_tax_row").live("click",function(){var t=e("#tax_rows .tax_row").size();e("#tax_rows").append('

×
');return!1});e("a.delete_tax_row").live("click",function(){$tax_row=e(this).closest(".tax_row");$tax_row.find("input").val("");$tax_row.hide();return!1});e("select#product-type").change(function(){var t=e(this).val();e(".hide_if_grouped, .hide_if_external").show();e(".show_if_simple, .show_if_variable, .show_if_grouped, .show_if_external").hide();if(t=="simple"){e(".show_if_simple").show();e("input#_manage_stock").change()}else if(t=="variable"){e(".show_if_variable").show();e("input#_manage_stock").change();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change()}else if(t=="grouped"){e(".show_if_grouped").show();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change();e(".hide_if_grouped").hide()}else if(t=="external"){e(".show_if_external").show();e("input#_downloadable").prop("checked",!1).change();e("input#_virtual").removeAttr("checked").change();e(".hide_if_external").hide()}e("ul.wc-tabs li:visible").eq(0).find("a").click();e("body").trigger("woocommerce-product-type-change",t,e(this))}).change();e("input#_downloadable").change(function(){e(".show_if_downloadable").hide();e("input#_downloadable").is(":checked")&&e(".show_if_downloadable").show();e(".downloads_tab").is(".active")&&e("ul.wc-tabs li:visible").eq(0).find("a").click()}).change();e("input#_virtual").change(function(){e(".show_if_virtual").hide();e(".hide_if_virtual").show();if(e("input#_virtual").is(":checked")){e(".show_if_virtual").show();e(".hide_if_virtual").hide()}}).change();e(".sale_price_dates_fields").each(function(){var t=e(this),n=!1,r=t.closest("div, table");t.find("input").each(function(){e(this).val()!=""&&(n=!0)});if(n){r.find(".sale_schedule").hide();r.find(".sale_price_dates_fields").show()}else{r.find(".sale_schedule").show();r.find(".sale_price_dates_fields").hide()}});e("#woocommerce-product-data").on("click",".sale_schedule",function(){var t=e(this).closest("div, table");e(this).hide();t.find(".cancel_sale_schedule").show();t.find(".sale_price_dates_fields").show();return!1});e("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var t=e(this).closest("div, table");e(this).hide();t.find(".sale_schedule").show();t.find(".sale_price_dates_fields").hide();t.find(".sale_price_dates_fields").find("input").val("");return!1});e("input#_manage_stock").change(function(){e(this).is(":checked")?e("div.stock_fields").show():e("div.stock_fields").hide()}).change();var t=e(".sale_price_dates_fields input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:!0,onSelect:function(n){var r=this.id=="_sale_price_dates_from"?"minDate":"maxDate",i=e(this).data("datepicker"),s=e.datepicker.parseDate(i.settings.dateFormat||e.datepicker._defaults.dateFormat,n,i.settings);t.not(this).datepicker("option",r,s)}});e(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:!0});e(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0});jQuery(".expand_all").click(function(){jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").show();return!1});jQuery(".close_all").click(function(){jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").hide();return!1});jQuery(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(t){if(e(t.target).filter(":input, option").length)return;jQuery(this).next(".wc-metabox-content").toggle()});jQuery(".wc-metabox.closed").each(function(){jQuery(this).find(".wc-metabox-content").hide()});e(".woocommerce_attributes select.multiselect").chosen();var n=e(".woocommerce_attributes").find(".woocommerce_attribute").get();n.sort(function(t,n){var r=parseInt(e(t).attr("rel")),i=parseInt(e(n).attr("rel"));return ri?1:0});e(n).each(function(t,n){e(".woocommerce_attributes").append(n)});e("button.add_attribute").on("click",function(){var t=e(".woocommerce_attributes .woocommerce_attribute").size(),n=e("select.attribute_taxonomy").val();if(!n){var i=e("select#product-type").val();i!="variable"?enable_variation='style="display:none;"':enable_variation="";e(".woocommerce_attributes").append('

")}else{var s=e(".woocommerce_attributes .woocommerce_attribute."+n);e(".woocommerce_attributes").append(e(s));e(s).show().find(".woocommerce_attribute_data").show();r()}e("select.attribute_taxonomy").val("")});e(".woocommerce_attributes").on("blur","input.attribute_name",function(){e(this).closest(".woocommerce_attribute").find("strong.attribute_name").text(e(this).val())});e(".woocommerce_attributes").on("click","button.select_all_attributes",function(){e(this).closest("td").find("select option").attr("selected","selected");e(this).closest("td").find("select").trigger("liszt:updated");return!1});e(".woocommerce_attributes").on("click","button.select_no_attributes",function(){e(this).closest("td").find("select option").removeAttr("selected");e(this).closest("td").find("select").trigger("liszt:updated");return!1});e(".woocommerce_attributes").on("click","button.remove_row",function(){var t=confirm(woocommerce_writepanel_params.remove_attribute);if(t){var n=e(this).parent().parent();if(n.is(".taxonomy")){n.find("select, input[type=text]").val("");n.hide()}else{n.find("select, input[type=text]").val("");n.hide();r()}}return!1});e(".woocommerce_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style");r()}});e(".woocommerce_attributes").on("click","button.add_new_attribute",function(){e(".woocommerce_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=e(this).attr("data-attribute"),n=e(this).closest(".woocommerce_attribute_data"),r=prompt(woocommerce_writepanel_params.new_attribute_prompt);if(r){var i={action:"woocommerce_add_new_attribute",taxonomy:t,term:r,security:woocommerce_writepanel_params.add_attribute_nonce};e.post(woocommerce_writepanel_params.ajax_url,i,function(t){result=jQuery.parseJSON(t);if(result.error)alert(result.error);else if(result.slug){n.find("select.attribute_values").append('");n.find("select.attribute_values").trigger("liszt:updated")}e(".woocommerce_attributes").unblock()})}else e(".woocommerce_attributes").unblock();return!1});var i;window.send_to_editor_default=window.send_to_editor;jQuery(".upload_file_button").live("click",function(){i=jQuery(this).parent().find(".file_paths");formfield=jQuery(i).attr("name");window.send_to_editor=window.send_to_download_url;tb_show("","media-upload.php?post_id="+woocommerce_writepanel_params.post_id+"&type=downloadable_product&from=wc01&TB_iframe=true");return!1});window.send_to_download_url=function(e){file_url=jQuery(e).attr("href");file_url&&jQuery(i).val(jQuery(i).val()?jQuery(i).val()+"\n"+file_url:file_url);tb_remove();window.send_to_editor=window.send_to_editor_default}});(function(e,t){function n(e){return!!(""===e||e&&e.charCodeAt&&e.substr)}function r(e){return c?c(e):"[object Array]"===h.call(e)}function i(e){return"[object Object]"===h.call(e)}function s(e,t){var n,e=e||{},t=t||{};for(n in t)t.hasOwnProperty(n)&&null==e[n]&&(e[n]=t[n]);return e}function o(e,t,n){var r=[],i,s;if(!e)return r;if(l&&e.map===l)return e.map(t,n);for(i=0,s=e.length;ie?"-":"",m=parseInt(d(Math.abs(e||0),c),10)+"",g=3e?g.neg:g.zero).replace("%s",d.symbol).replace("%v",v(Math.abs(e),u(d.precision),d.thousand,d.decimal))};f.formatColumn=function(e,t,l,c,h,d){if(!e)return[];var m=s(i(t)?t:{symbol:t,precision:l,thousand:c,decimal:h,format:d},f.settings.currency),g=a(m.format),y=g.pos.indexOf("%s")e?g.neg:g.zero).replace("%s",m.symbol).replace("%v",v(Math.abs(e),u(m.precision),m.thousand,m.decimal));e.length>b&&(b=e.length);return e});return o(e,function(e){return n(e)&&e.length