Added Customs Fields in back-end but can’t Save
-
Hello,
I tried to add some custom fields to a product page.
For this moment, I can add a custom field in General Part but I have an issue to save the information.Here my code
//-------- I Create NEW Field on the General Part --------- // function woo_add_custom_general_fields() { echo '<div style="background:#f8fbca;">'; woocommerce_wp_text_input( array( 'id' => 'CUSTOM_FIELD', 'label' => __('FIELD', 'woo'), 'placeholder' => __('xxxxxxxx', 'woo'), 'description' => __('xxxxxxxx', 'woo'), 'desc_tip' => false, ) ); echo '</div>'; } add_action('woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields');
But the part I can’t found the solution is this one:
//-------- I save the NEW Field --------- // function woo_add_custom_general_fields_save($post_id) { $CUSTOM_FIELD = $_POST['_field']; if(!empty($CUSTOM_FIELD)) update_post_meta($post_id, '_field', esc_attr($CUSTOM_FIELD)); } add_action('woocommerce_process_product_meta', 'woo_add_custom_general_fields_save');
I can’t save it, after save the product page, the field stay blank..
Where is my mistake?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Added Customs Fields in back-end but can’t Save’ is closed to new replies.