admin管理员组

文章数量:1389783

I would like to add a field in WooCommerce checkout page. I would like to use below code.

add_filter( 'woocommerce_checkout_fields' , 'my_override_checkout_fields' );

But in which file should I put this code ?

I would like to add a field in WooCommerce checkout page. I would like to use below code.

add_filter( 'woocommerce_checkout_fields' , 'my_override_checkout_fields' );

But in which file should I put this code ?

Share Improve this question asked Apr 2, 2020 at 6:07 FoysalFoysal 4451 gold badge5 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: Adding Field in WooCommerce