Try adding this code to your add_action ‘init’ function.
// Let WooCommerce add a new custom endpoint "earnings" for you
add_filter( 'woocommerce_get_query_vars', function( $vars ) {
$vars['earnings'] = 'earnings';
return $vars;
} );
// Add "earnings" to the WooCommerce account menu
add_filter( 'woocommerce_account_menu_items', function( $items ) {
$items['earnings'] = __( 'My earnings', 'your-text-domain' );
return $items;
} );
// Display your custom title on the new endpoint page
// Pattern: woocommerce_endpoint_{$your_endpoint}_title
add_filter( 'woocommerce_endpoint_earnings_title', function( $title ) {
return __( 'My earnings', 'your-text-domain' );
} );
// Display your custom content on the new endpoint page
// Pattern: woocommerce_account_{$your_endpoint}_endpoint
add_action( 'woocommerce_account_earnings_endpoint', function() {
echo __( 'Hello World', 'your-text-domain' );
} );
// Only for testing, REMOVE afterwards!
flush_rewrite_rules();