EDIT: используется woocommerce_admin_process_product_object
для сохранения вместо устаревшего woocommerce_process_product_meta
. Спасибо: @ LoicTheAzte c
// Add field
function product_certification_number() {
$args = array(
'id' => '_product_certification_number',
'label' => __( 'Product Certification Number', 'woocommerce' ),
'class' => 'custom-field',
'desc_tip' => true,
'description' => __( 'My description', 'woocommerce' ),
);
woocommerce_wp_text_input( $args );
}
add_action('woocommerce_product_options_general_product_data','product_certification_number', 10, 0 );
// Save
function product_certification_number_save( $product ){
if( isset($_POST['_product_certification_number']) ) {
$product->update_meta_data( '_product_certification_number', sanitize_text_field( $_POST['_product_certification_number'] ) );
}
}
add_action( 'woocommerce_admin_process_product_object', 'product_certification_number_save', 10, 1 );