Home › Forums › WoodMart support forum › How to Bulk Edit Initial number in stock › Reply To: How to Bulk Edit Initial number in stock
November 28, 2023 at 11:38 am
#516257
Luke Nielsen
Keymaster
Hello,
I apologize for the confusion we experienced.
Paste the below code to the child theme.
add_action( 'woocommerce_product_bulk_edit_end', function () {
?>
<div class="inline-edit-group dimensions">
<label class="alignleft">
<span class="title">
<?php esc_html_e( 'Initial number in stock', 'woodmart' ); ?>
</span>
<span class="input-text-wrap">
<select class="change_dimensions change_to" name="change_woodmart_total_stock_quantity">
<option value=""><?php esc_html_e( '— No change —', 'woocommerce' ); ?></option>
<option value="1"><?php esc_html_e( 'Change to:', 'woocommerce' ); ?></option>
</select>
</span>
</label>
<label class="change-input">
<input type="text" name="woodmart_total_stock_quantity" class="text stock woodmart_total_stock_quantity" placeholder="<?php esc_attr_e( 'Initial number in stock', 'woodmart' ); ?>" value="">
</label>
</div>
<?php
});
add_action( 'save_post_product', function () {
if ( ! isset( $_GET['post'] ) || ! isset( $_GET['change_woodmart_total_stock_quantity'] ) || ! $_GET['change_woodmart_total_stock_quantity'] || ! isset( $_GET['woodmart_total_stock_quantity'] ) ) { //phpcs:ignore
return;
}
$posts_id = woodmart_clean( $_GET['post'] ); //phpcs:ignore
$option = wp_kses( $_GET['woodmart_total_stock_quantity'], true ); //phpcs:ignore
if ( $posts_id ) {
foreach ( $posts_id as $id ) {
update_post_meta( $id, 'woodmart_total_stock_quantity', $option );
}
}
} );
Kind Regards