Adding Field in WooCommerce

The short, common answer is:

Inside functions.php file in your theme.

The more advanced answer is:

Well… In any file that is included and executed.

One way is to create your own plugin and put that line inside it.

Another way is to put it in functions.php file in your theme.

Remember, that you should never modify ready themes, so if you use one, you should create a child theme and put that code inside it.

And of course it doesn’t need to be exactly functions.php – you can create any file (like inc/woo-functions.php), put that code inside it and then include it in your functions.php file.