I created textarea field to save woocommerce products notes, i want to save these notes into admin order if any product available in cart and have product notes.
// WooCommerce Products Custom Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Textarea Field
woocommerce_wp_textarea_input(
array(
'id' => 'product_notes',
'label' => __( 'Product Notes', 'woocommerce' ),
'placeholder' => 'Enter product notes here.',
'desc_tip' => 'true',
'description' => __( 'Enter product notes here.', 'woocommerce' )
)
);
echo '</div>';
}
// Save Product notes
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
function woo_add_custom_general_fields_save( $post_id ){
// Textarea
$woocommerce_textarea = $_POST['product_notes'];
if( !empty( $woocommerce_textarea ) )
update_post_meta( $post_id, 'product_notes', esc_html( $woocommerce_textarea ) );
}
</div>