Home Forums WoodMart support forum How to Bulk Edit Initial number in stock

How to Bulk Edit Initial number in stock

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #514955

    z976937999
    Participant

    I have 2000 items, how can I batch edit Initial number in stock attribute?

    #514993

    Luke Nielsen
    Keymaster

    Hello,

    In the Dashboard -> Products, open the “Screen options” and increase the items per page, thus you can bulk for 500 or more products.

    https://take.ms/aO9en

    Kind Regards

    #514994

    z976937999
    Participant

    Can you edit the ‘Initial number in stock’ attribute, I don’t see an option for it in the bulk edit area.

    #515012

    Luke Nielsen
    Keymaster

    Hello,

    Please read the below article for help:

    https://ithemelandco.com/blog/bulk-edit-product-stock-in-woocommerce/

    Thank you for your time.

    Kind Regards

    • This reply was modified 1 year, 1 month ago by Luke Nielsen.
    #515251

    z976937999
    Participant

    There is no attribute here like I want to set, I want to set the ‘Initial number in stock’ attribute in bulk, if there is no good way to do this, can you tell me which table and field in the database can set this attribute?

    Attachments:
    You must be logged in to view attached files.
    #515258

    Luke Nielsen
    Keymaster

    Hello,

    In the woodmart_total_stock_quantity field of wp_postmeta table.

    Thank you for your time.

    Kind Regards

    #515262

    z976937999
    Participant

    Can you write me a SQL to change the woodmart_total_stock_quantity field to 100 for all the products, it will help me a lot.

    #515337

    Luke Nielsen
    Keymaster

    Hello,

    Sorry, but such Customization is not included in our support, it is beyond our limitations and support policy scope. Hope you can understand our limitations.

    Don’t hesitate to let me know if you need any further help or any other info

    Kind Regards

    #515366

    z976937999
    Participant

    Is there any plugin or method to bulk edit this attribute, the method in the above reply can only bulk edit the stock attribute provided by woocommerce, but not ‘Initial number in stock’.

    #515759

    Luke Nielsen
    Keymaster

    Hello,

    The “Initial number in stock” is provided by WooCommerce as well, so I suggest you contact their support team for further solutions because our theme cannot influence the functionality that comes from WooCommerce.

    Thank you for your time.

    Kind Regards

    #515802

    z976937999
    Participant

    But this attribute has the field ‘woodmart_total_stock_quantity’ in the database, are you sure it’s a woocommerce attribute?

    #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

    #516284

    z976937999
    Participant

    Thanks, my problem has been solved

    #516288

    Luke Nielsen
    Keymaster

    Hello,

    You are welcome!

    If you do not mind, can you please leave 5 stars rating for our theme by going here: http://themeforest.net/downloads It will allow us to release more updates and provide dedicated support in future. It would encourage our work a lot.

    Have a good day!

    Kind Regards

Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘How to Bulk Edit Initial number in stock’ is closed to new replies.