Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

php - WordPress/WooCommerce - What is the hook for custom category bulk edit?

I have added bulk action in the WooCommerce product category edit. I just want to know what the hook is when I click on Apply to do some actions on selected categories. (Specifically, I want to update all selected categories by updating the wp_termmeta table and set the example value to 1 or 0) The only thing that I want is the name of the hook when clicking the Apply button in /wp-admin/edit-tags.php?taxonomy=product_cat&post_type=product.

Bulk Action

question from:https://stackoverflow.com/questions/65844366/wordpress-woocommerce-what-is-the-hook-for-custom-category-bulk-edit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just copy & paste into your functions.php. Enjoy

// Note: change all occurrences of "custom_field" with the key of your custom field add_action( 'woocommerce_product_bulk_edit_start', 'bbloomer_custom_field_bulk_edit_input' ); function bbloomer_custom_field_bulk_edit_input() { ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e( 'Custom Field', 'woocommerce' ); ?></span> <span class="input-text-wrap"> <input type="text" name="custom_field" class="text" value=""> </span> </label> </div> <?php } add_action( 'woocommerce_product_bulk_edit_save', 'bbloomer_custom_field_bulk_edit_save' ); function bbloomer_custom_field_bulk_edit_save( $product ) { $post_id = $product->get_id(); if ( isset( $_REQUEST['custom_field'] ) ) { $custom_field = $_REQUEST['custom_field']; update_post_meta( $post_id, 'custom_field', wc_clean( $custom_field ) ); } }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...