Bulk and quick edit tax status/class. Closes #3530.
This commit is contained in:
parent
63433bbdd7
commit
12d705c9c4
|
@ -1,14 +1,14 @@
|
|||
jQuery(document).ready(function(){
|
||||
jQuery('#the-list').on('click', '.editinline', function(){
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('#the-list').on('click', '.editinline', function(){
|
||||
|
||||
inlineEditPost.revert();
|
||||
|
||||
var post_id = jQuery(this).closest('tr').attr('id');
|
||||
|
||||
|
||||
post_id = post_id.replace("post-", "");
|
||||
|
||||
|
||||
var $wc_inline_data = jQuery('#woocommerce_inline_' + post_id );
|
||||
|
||||
|
||||
var sku = $wc_inline_data.find('.sku').text();
|
||||
var regular_price = $wc_inline_data.find('.regular_price').text();
|
||||
var sale_price = $wc_inline_data.find('.sale_price').text();
|
||||
|
@ -22,90 +22,95 @@ jQuery(document).ready(function(){
|
|||
var featured = $wc_inline_data.find('.featured').text();
|
||||
var manage_stock = $wc_inline_data.find('.manage_stock').text();
|
||||
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();
|
||||
|
||||
jQuery('input[name="_sku"]', '.inline-edit-row').val(sku);
|
||||
jQuery('input[name="_regular_price"]', '.inline-edit-row').val(regular_price);
|
||||
jQuery('input[name="_sale_price"]', '.inline-edit-row').val(sale_price);
|
||||
jQuery('input[name="_weight"]', '.inline-edit-row').val(weight);
|
||||
jQuery('input[name="_length"]', '.inline-edit-row').val(length);
|
||||
jQuery('input[name="_width"]', '.inline-edit-row').val(width);
|
||||
jQuery('input[name="_sale_price"]', '.inline-edit-row').val(sale_price);
|
||||
jQuery('input[name="_weight"]', '.inline-edit-row').val(weight);
|
||||
jQuery('input[name="_length"]', '.inline-edit-row').val(length);
|
||||
jQuery('input[name="_width"]', '.inline-edit-row').val(width);
|
||||
jQuery('input[name="_height"]', '.inline-edit-row').val(height);
|
||||
jQuery('input[name="_stock"]', '.inline-edit-row').val(stock);
|
||||
jQuery('input[name="menu_order"]', '.inline-edit-row').val(menu_order);
|
||||
|
||||
jQuery('input[name="_stock"]', '.inline-edit-row').val(stock);
|
||||
jQuery('input[name="menu_order"]', '.inline-edit-row').val(menu_order);
|
||||
|
||||
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[value="' + visibility + '"]', '.inline-edit-row').attr('selected', 'selected');
|
||||
jQuery('select[name="_stock_status"] option[value="' + stock_status + '"]', '.inline-edit-row').attr('selected', 'selected');
|
||||
|
||||
|
||||
if (featured=='yes') {
|
||||
jQuery('input[name="_featured"]', '.inline-edit-row').attr('checked', 'checked');
|
||||
jQuery('input[name="_featured"]', '.inline-edit-row').attr('checked', 'checked');
|
||||
} else {
|
||||
jQuery('input[name="_featured"]', '.inline-edit-row').removeAttr('checked');
|
||||
jQuery('input[name="_featured"]', '.inline-edit-row').removeAttr('checked');
|
||||
}
|
||||
|
||||
|
||||
if (manage_stock=='yes') {
|
||||
jQuery('.stock_qty_field', '.inline-edit-row').show().removeAttr('style');
|
||||
jQuery('input[name="_manage_stock"]', '.inline-edit-row').attr('checked', 'checked');
|
||||
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');
|
||||
jQuery('input[name="_manage_stock"]', '.inline-edit-row').removeAttr('checked');
|
||||
}
|
||||
|
||||
|
||||
// Conditional display
|
||||
var product_type = $wc_inline_data.find('.product_type').text();
|
||||
var product_is_virtual = $wc_inline_data.find('.product_is_virtual').text();
|
||||
|
||||
|
||||
if (product_type=='simple' || product_type=='external') {
|
||||
jQuery('.price_fields', '.inline-edit-row').show().removeAttr('style');
|
||||
} else {
|
||||
jQuery('.price_fields', '.inline-edit-row').hide();
|
||||
}
|
||||
|
||||
|
||||
if (product_is_virtual=='yes') {
|
||||
jQuery('.dimension_fields', '.inline-edit-row').hide();
|
||||
} else {
|
||||
jQuery('.dimension_fields', '.inline-edit-row').show().removeAttr('style');
|
||||
}
|
||||
|
||||
|
||||
if (product_type=='grouped') {
|
||||
jQuery('.stock_fields', '.inline-edit-row').hide();
|
||||
} else {
|
||||
jQuery('.stock_fields', '.inline-edit-row').show().removeAttr('style');
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('#the-list').on('change', '.inline-edit-row input[name="_manage_stock"]', function(){
|
||||
|
||||
});
|
||||
|
||||
jQuery('#the-list').on('change', '.inline-edit-row input[name="_manage_stock"]', function(){
|
||||
|
||||
if (jQuery(this).is(':checked')) {
|
||||
jQuery('.stock_qty_field', '.inline-edit-row').show().removeAttr('style');
|
||||
} else {
|
||||
jQuery('.stock_qty_field', '.inline-edit-row').hide();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
jQuery('#wpbody').on('click', '#doaction, #doaction2', function(){
|
||||
|
||||
jQuery('#wpbody').on('click', '#doaction, #doaction2', function(){
|
||||
|
||||
jQuery('select, input.text', '.inline-edit-row').val('');
|
||||
jQuery('select option', '.inline-edit-row').removeAttr('checked');
|
||||
jQuery('#woocommerce-fields-bulk .inline-edit-group .alignright').hide();
|
||||
|
||||
|
||||
});
|
||||
|
||||
jQuery('#wpbody').on('change', '#woocommerce-fields-bulk .inline-edit-group .change_to', function(){
|
||||
|
||||
|
||||
jQuery('#wpbody').on('change', '#woocommerce-fields-bulk .inline-edit-group .change_to', function(){
|
||||
|
||||
if (jQuery(this).val() > 0) {
|
||||
jQuery(this).closest('div').find('.alignright').show();
|
||||
} else {
|
||||
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');
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
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("select option",".inline-edit-row").removeAttr("checked");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")})});
|
|
@ -181,6 +181,8 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
|
|||
<div class="featured">' . $the_product->featured . '</div>
|
||||
<div class="product_type">' . $the_product->product_type . '</div>
|
||||
<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>
|
||||
';
|
||||
|
||||
|
@ -564,6 +566,12 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
|
|||
if ( isset( $_REQUEST['_visibility'] ) ) update_post_meta( $post_id, '_visibility', woocommerce_clean( $_REQUEST['_visibility'] ) );
|
||||
if ( isset( $_REQUEST['_featured'] ) ) update_post_meta( $post_id, '_featured', 'yes' ); else update_post_meta( $post_id, '_featured', 'no' );
|
||||
|
||||
if ( isset( $_REQUEST['_tax_status'] ) )
|
||||
update_post_meta( $post_id, '_tax_status', woocommerce_clean( $_REQUEST['_tax_status'] ) );
|
||||
|
||||
if ( isset( $_REQUEST['_tax_class'] ) )
|
||||
update_post_meta( $post_id, '_tax_class', woocommerce_clean( $_REQUEST['_tax_class'] ) );
|
||||
|
||||
if ( $product->is_type('simple') || $product->is_type('external') ) {
|
||||
|
||||
if ( isset( $_REQUEST['_regular_price'] ) ) update_post_meta( $post_id, '_regular_price', woocommerce_clean( $_REQUEST['_regular_price'] ) );
|
||||
|
@ -611,15 +619,25 @@ class WC_Admin_CPT_Product extends WC_Admin_CPT {
|
|||
|
||||
// Save fields
|
||||
if ( ! empty( $_REQUEST['change_weight'] ) && isset( $_REQUEST['_weight'] ) )
|
||||
update_post_meta( $post_id, '_weight', esc_html( stripslashes( $_REQUEST['_weight'] ) ) );
|
||||
update_post_meta( $post_id, '_weight', woocommerce_clean( stripslashes( $_REQUEST['_weight'] ) ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['change_dimensions'] ) ) {
|
||||
if ( isset( $_REQUEST['_length'] ) )
|
||||
update_post_meta( $post_id, '_length', esc_html( stripslashes( $_REQUEST['_length'] ) ) );
|
||||
update_post_meta( $post_id, '_length', woocommerce_clean( stripslashes( $_REQUEST['_length'] ) ) );
|
||||
if ( isset( $_REQUEST['_width'] ) )
|
||||
update_post_meta( $post_id, '_width', esc_html( stripslashes( $_REQUEST['_width'] ) ) );
|
||||
update_post_meta( $post_id, '_width', woocommerce_clean( stripslashes( $_REQUEST['_width'] ) ) );
|
||||
if ( isset( $_REQUEST['_height'] ) )
|
||||
update_post_meta( $post_id, '_height', esc_html( stripslashes( $_REQUEST['_height'] ) ) );
|
||||
update_post_meta( $post_id, '_height', woocommerce_clean( stripslashes( $_REQUEST['_height'] ) ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['_tax_status'] ) )
|
||||
update_post_meta( $post_id, '_tax_status', woocommerce_clean( $_REQUEST['_tax_status'] ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['_tax_class'] ) ) {
|
||||
$tax_class = woocommerce_clean( $_REQUEST['_tax_class'] );
|
||||
if ( $tax_class == 'standard' )
|
||||
$tax_class = '';
|
||||
update_post_meta( $post_id, '_tax_class', $tax_class );
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['_stock_status'] ) )
|
||||
|
|
|
@ -54,6 +54,49 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<span class="title"><?php _e( 'Tax Status', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
<select class="tax_status" name="_tax_status">
|
||||
<?php
|
||||
$options = array(
|
||||
'' => __( '— No Change —', 'woocommerce' ),
|
||||
'taxable' => __( 'Taxable', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping only', 'woocommerce' ),
|
||||
'none' => __( 'None', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span class="title"><?php _e( 'Tax Class', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
<select class="tax_class" name="_tax_class">
|
||||
<?php
|
||||
$options = array(
|
||||
'' => __( '— No Change —', 'woocommerce' ),
|
||||
'standard' => __( 'Standard', 'woocommerce' )
|
||||
);
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
|
||||
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$options[ sanitize_title( $class ) ] = esc_html( $class );
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<?php if ( get_option('woocommerce_enable_weight') == "yes" ) : ?>
|
||||
<div class="inline-edit-group">
|
||||
<label class="alignleft">
|
||||
|
@ -66,7 +109,7 @@
|
|||
'1' => __( 'Change to:', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -90,7 +133,7 @@
|
|||
'1' => __( 'Change to:', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -117,7 +160,7 @@
|
|||
'hidden' => __( 'Hidden', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -134,7 +177,7 @@
|
|||
'no' => __( 'No', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -152,13 +195,14 @@
|
|||
'outofstock' => __( 'Out of stock', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<?php if (get_option('woocommerce_manage_stock')=='yes') : ?>
|
||||
|
||||
<label>
|
||||
<span class="title"><?php _e( 'Manage stock?', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
|
@ -170,14 +214,14 @@
|
|||
'no' => __( 'No', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<div class="inline-edit-group dimensions">
|
||||
<div class="inline-edit-group">
|
||||
<label class="alignleft stock_qty_field">
|
||||
<span class="title"><?php _e( 'Stock Qty', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
|
@ -188,7 +232,7 @@
|
|||
'1' => __( 'Change to:', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="'.$key.'">'. $value .'</option>';
|
||||
echo '<option value="' . $key . '">'. $value .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -199,9 +243,9 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<?php endif;
|
||||
<?php endif; ?>
|
||||
|
||||
do_action( 'woocommerce_product_bulk_edit_end' ); ?>
|
||||
<?php do_action( 'woocommerce_product_bulk_edit_end' ); ?>
|
||||
|
||||
<input type="hidden" name="woocommerce_bulk_edit" value="1" />
|
||||
<input type="hidden" name="woocommerce_bulk_edit_nonce" value="<?php echo wp_create_nonce( 'woocommerce_bulk_edit_nonce' ); ?>" />
|
||||
|
|
|
@ -32,6 +32,48 @@
|
|||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<label class="alignleft">
|
||||
<span class="title"><?php _e( 'Tax Status', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
<select class="tax_status" name="_tax_status">
|
||||
<?php
|
||||
$options = array(
|
||||
'taxable' => __( 'Taxable', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping only', 'woocommerce' ),
|
||||
'none' => __( 'None', 'woocommerce' )
|
||||
);
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<br class="clear" />
|
||||
<label class="alignleft">
|
||||
<span class="title"><?php _e( 'Tax Class', 'woocommerce' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
<select class="tax_class" name="_tax_class">
|
||||
<?php
|
||||
$options = array(
|
||||
'' => __( 'Standard', 'woocommerce' )
|
||||
);
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
|
||||
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$options[ sanitize_title( $class ) ] = esc_html( $class );
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<br class="clear" />
|
||||
|
||||
<?php if ( get_option('woocommerce_enable_weight') == "yes" || get_option('woocommerce_enable_dimensions') == "yes" ) : ?>
|
||||
<div class="dimension_fields">
|
||||
|
||||
|
|
Loading…
Reference in New Issue