Fügen Sie WooCommerce -Abonnements benutzerdefiniertes Feld hinzu

// Showing custom fields on admin product settings "general" tab
add_action('woocommerce_product_options_general_product_data', 'add_admin_product_custom_fields', 10, 3);
function add_admin_product_custom_fields() {
    global $post;
    
    echo '<div class="product_custom_field show_if_simple show_if_subscription">';
    
    woocommerce_wp_text_input( array(
        'id'            => 'my_text_field',
        'name'          => 'my_text_field',
        'label'         => __('Some label', 'woocommerce'),
    ) );
    
    echo '</div>';
}

// Saving custom fields values from admin product settings
add_action('woocommerce_admin_process_product_object', 'save_admin_product_custom_fields_values');
function save_admin_product_custom_fields_values( $product ) {
    if ( isset($_POST['my_text_field']) ) {
        $product->update_meta_data( 'my_text_field', sanitize_text_field($_POST['my_text_field']) );
    }
}
OussamaDEV