Не сохраняются кастомные поля WooCommerce (Radio)

Делал по статье кастомные поля с сохранением, но почему-то не сохраняет данные в БД (файл function.php). Пытался сделать также через Select, тот же эффект, возвращает "id":160542,"key":"_custom_field_radio","value":""

    function cfwc_create_custom_field ( ) {
        global $post;
        $product = wc_get_product( $post->ID );
        $title = $product->get_meta( '_custom_field_radio' );
        echo wc_get_product( $post->ID );
        $args = array ( 
            'label' => '' , // Текст в метке 
            'class' => '' , 
            'style' => '' , 
            'value' => '', // если пусто, получено из мета поста, где id это ключ meta_key 
            'id' => '_custom_field_radio' , // требуется 
            'name' => 'unit' , // имя будет установлено из id, если пусто 
            'options' => array(
                '' => 'PCS',
                'kg' => 'KG'
            ) , // Опции для радиовходов, массив 
            'desc_tip' => '' , 
            'description' => '' 
            ); 
        woocommerce_wp_radio($args);
    }
    add_action('woocommerce_product_options_general_product_data', 'cfwc_create_custom_field');

    function cfwc_save_custom_field( $post_id ) {
        $product = wc_get_product( $post_id );
        $title = isset( $_POST['_custom_field_radio'] ) ? $_POST['_custom_field_radio'] : '';
        $product->update_meta_data( '_custom_field_radio', sanitize_text_field( $title ) );
        $product->save();
    }
    add_action( 'woocommerce_process_product_meta', 'cfwc_save_custom_field' );

Ответы (0 шт):