Bulk/quick edit backorders Closes #3729

This commit is contained in:
Mike Jolley 2013-09-06 11:17:41 +01:00
parent 9cdb3821e2
commit 3c8c620c5d
5 changed files with 51 additions and 3 deletions

View File

@ -24,6 +24,7 @@ jQuery(document).ready(function(){
var menu_order = $wc_inline_data.find('.menu_order').text();
var tax_status = $wc_inline_data.find('.tax_status').text();
var tax_class = $wc_inline_data.find('.tax_class').text();
var backorders = $wc_inline_data.find('.backorders').text();
jQuery('input[name="_sku"]', '.inline-edit-row').val(sku);
jQuery('input[name="_regular_price"]', '.inline-edit-row').val(regular_price);
@ -38,10 +39,11 @@ jQuery(document).ready(function(){
jQuery('select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row').attr('selected', 'selected');
jQuery('select[name="_tax_class"] option[value="' + tax_class + '"]', '.inline-edit-row').attr('selected', 'selected');
jQuery('select[name="_visibility"] option, select[name="_stock_status"] option').removeAttr('selected');
jQuery('select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr('selected');
jQuery('select[name="_visibility"] option[value="' + visibility + '"]', '.inline-edit-row').attr('selected', 'selected');
jQuery('select[name="_stock_status"] option[value="' + stock_status + '"]', '.inline-edit-row').attr('selected', 'selected');
jQuery('select[name="_backorders"] option[value="' + backorders + '"]', '.inline-edit-row').attr('selected', 'selected');
if (featured=='yes') {
jQuery('input[name="_featured"]', '.inline-edit-row').attr('checked', 'checked');
@ -91,7 +93,8 @@ jQuery(document).ready(function(){
});
jQuery('#wpbody').on('click', '#doaction, #doaction2', function(){
jQuery('select, input.text', '.inline-edit-row').val('');
jQuery('input.text', '.inline-edit-row').val('');
jQuery('select').prop('selectedIndex',0);
jQuery('#woocommerce-fields-bulk .inline-edit-group .alignright').hide();
});

View File

@ -1 +0,0 @@
jQuery(document).ready(function(){jQuery("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var e=jQuery(this).closest("tr").attr("id");e=e.replace("post-","");var t=jQuery("#woocommerce_inline_"+e),n=t.find(".sku").text(),r=t.find(".regular_price").text(),i=t.find(".sale_price").text(),s=t.find(".weight").text(),o=t.find(".length").text(),u=t.find(".width").text(),a=t.find(".height").text(),f=t.find(".visibility").text(),l=t.find(".stock_status").text(),c=t.find(".stock").text(),h=t.find(".featured").text(),p=t.find(".manage_stock").text(),d=t.find(".menu_order").text(),v=t.find(".tax_status").text(),m=t.find(".tax_class").text();jQuery('input[name="_sku"]',".inline-edit-row").val(n);jQuery('input[name="_regular_price"]',".inline-edit-row").val(r);jQuery('input[name="_sale_price"]',".inline-edit-row").val(i);jQuery('input[name="_weight"]',".inline-edit-row").val(s);jQuery('input[name="_length"]',".inline-edit-row").val(o);jQuery('input[name="_width"]',".inline-edit-row").val(u);jQuery('input[name="_height"]',".inline-edit-row").val(a);jQuery('input[name="_stock"]',".inline-edit-row").val(c);jQuery('input[name="menu_order"]',".inline-edit-row").val(d);jQuery('select[name="_tax_status"] option[value="'+v+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_tax_class"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_visibility"] option, select[name="_stock_status"] option').removeAttr("selected");jQuery('select[name="_visibility"] option[value="'+f+'"]',".inline-edit-row").attr("selected","selected");jQuery('select[name="_stock_status"] option[value="'+l+'"]',".inline-edit-row").attr("selected","selected");h=="yes"?jQuery('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):jQuery('input[name="_featured"]',".inline-edit-row").removeAttr("checked");if(p=="yes"){jQuery(".stock_qty_field",".inline-edit-row").show().removeAttr("style");jQuery('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")}else{jQuery(".stock_qty_field",".inline-edit-row").hide();jQuery('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked")}var g=t.find(".product_type").text(),y=t.find(".product_is_virtual").text();g=="simple"||g=="external"?jQuery(".price_fields",".inline-edit-row").show().removeAttr("style"):jQuery(".price_fields",".inline-edit-row").hide();y=="yes"?jQuery(".dimension_fields",".inline-edit-row").hide():jQuery(".dimension_fields",".inline-edit-row").show().removeAttr("style");g=="grouped"?jQuery(".stock_fields",".inline-edit-row").hide():jQuery(".stock_fields",".inline-edit-row").show().removeAttr("style")});jQuery("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){jQuery(this).is(":checked")?jQuery(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):jQuery(".stock_qty_field",".inline-edit-row").hide()});jQuery("#wpbody").on("click","#doaction, #doaction2",function(){jQuery("select, input.text",".inline-edit-row").val("");jQuery("#woocommerce-fields-bulk .inline-edit-group .alignright").hide()});jQuery("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){jQuery(this).val()>0?jQuery(this).closest("div").find(".alignright").show():jQuery(this).closest("div").find(".alignright").hide()});jQuery(".product_shipping_class-checklist input").change(function(){jQuery(this).closest("li").siblings().find("input:checked").removeAttr("checked")})});

View File

@ -304,6 +304,7 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
<div class="product_is_virtual">' . $the_product->virtual . '</div>
<div class="tax_status">' . $the_product->tax_status . '</div>
<div class="tax_class">' . $the_product->tax_class . '</div>
<div class="backorders">' . $the_product->backorders . '</div>
</div>
';
@ -728,6 +729,10 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
update_post_meta( $post_id, '_manage_stock', 'no' );
wc_update_product_stock( $post_id, 0 );
}
if ( ! empty( $_REQUEST['_backorders'] ) ) {
update_post_meta( $post_id, '_backorders', woocommerce_clean( $_REQUEST['_backorders'] ) );
}
}
do_action( 'woocommerce_product_quick_edit_save', $product );
@ -889,6 +894,10 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
}
}
if ( ! empty( $_REQUEST['_backorders'] ) ) {
update_post_meta( $post_id, '_backorders', woocommerce_clean( $_REQUEST['_backorders'] ) );
}
}
do_action( 'woocommerce_product_bulk_edit_save', $product );

View File

@ -243,6 +243,25 @@
</label>
</div>
<label>
<span class="title"><?php _e( 'Backorders?', 'woocommerce' ); ?></span>
<span class="input-text-wrap">
<select class="backorders" name="_backorders">
<?php
$options = array(
'' => __( '— No Change —', 'woocommerce' ),
'no' => __( 'Do not allow', 'woocommerce' ),
'notify' => __( 'Allow, but notify customer', 'woocommerce' ),
'yes' => __( 'Allow', 'woocommerce' )
);
foreach ($options as $key => $value) {
echo '<option value="' . $key . '">'. $value .'</option>';
}
?>
</select>
</span>
</label>
<?php endif; ?>
<?php do_action( 'woocommerce_product_bulk_edit_end' ); ?>

View File

@ -163,6 +163,24 @@
</div>
<label class="alignleft">
<span class="title"><?php _e( 'Backorders?', 'woocommerce' ); ?></span>
<span class="input-text-wrap">
<select class="backorders" name="_backorders">
<?php
$options = array(
'no' => __( 'Do not allow', 'woocommerce' ),
'notify' => __( 'Allow, but notify customer', 'woocommerce' ),
'yes' => __( 'Allow', 'woocommerce' )
);
foreach ($options as $key => $value) {
echo '<option value="'.$key.'">'. $value .'</option>';
}
?>
</select>
</span>
</label>
<?php do_action( 'woocommerce_product_quick_edit_end' ); ?>
<input type="hidden" name="woocommerce_quick_edit" value="1" />