how to change hooks properly?
-
Hi there,
I got this snippet (below this) to add checkbox custom field which is auto set and it’s working fine.
add_action( 'woocommerce_product_options_pricing', 'add_custom_field_product_options_pricing' ); function add_custom_field_product_options_pricing() { global $product_object; echo '</div><div class="options_group">'; $values = $product_object->get_meta('_cutom_meta_key'); woocommerce_wp_checkbox( array( // Checkbox. 'id' => '_cutom_meta_key', 'label' => __( 'Custom label', 'woocommerce' ), 'value' => empty($values) ? 'yes' : $values, 'description' => __( 'Enable this to make something.', 'woocommerce' ), ) ); } // Save quantity setting fields values add_action( 'woocommerce_admin_process_product_object', 'save_custom_field_product_options_pricing' ); function save_custom_field_product_options_pricing( $product ) { $product->update_meta_data( '_cutom_meta_key', isset($_POST['_cutom_meta_key']) ? 'yes' : 'no' ); }
My question, how to move this checkbox to be on the inventory tab?
I’ve tried changing :
this :
add_action( 'woocommerce_product_options_pricing', 'add_custom_field_product_options_pricing' );
to this :
add_action( 'woocommerce_product_options_inventory_product_data', 'add_custom_field_product_options_pricing' );
and
this :
add_action( 'woocommerce_admin_process_product_object', 'save_custom_field_product_options_pricing' );
to this
add_action( 'woocommerce_process_product_meta', 'save_custom_field_product_options_pricing' );
but to no avail.
Please guide me,
thank you
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘how to change hooks properly?’ is closed to new replies.