Question about editing functions.php to add custom fields in WooCommerce checkout page

Hello everyone,

I am not a developer and I wanted to add the feature mentioned here: Add a required checkbox field in WooCommerce checkout page

Can I just do as the tutorial says and edit the functions.php under theme settings or would I break things if I do so?

Many thanks in advance for your help.

Normally, the procedure is correct, but whether it works or not, no one here will be able to answer clearly.
I would not try it on a live website. Test it on a staging site or a local test environment.

1 Like

Thank you for your help. I remember reading something about not adding custom code to the main theme that was one of the reasons why I asked the question. Should I create the so called “child theme”?

It is indeed consider as a good practice to edit the file functions.php of the child theme.

To download the child theme, just go directly to your bricks accounts: Account – Bricks

After that, upload it as a Wordpress theme and activate it.

Finally, go to the “Theme File Editor” of Wordpress to edit it.

Thank you!
One final question: changin theme to child theme would not break my design, right? :slight_smile: Sorry for noob questions.

Hi Rational,

No problem, all questions are always good.
Regarding the child theme, don’t worry. You can go ahead, it will not break your design.

And if that’s the unlikely case, you can always reactivate the parent theme instead of the child one.

Any changes to the theme files should only ever be made in the child theme, just as HomeSweetTom said.
Instead of editing the function.php directly in Wordpress, you can also use an external editor like VScode. I have to download the funktions.php and upload it again after editing, but I can save multiple versions of the funktions.php by doing this. If a change does not work, I can undo all changes by using the previous version, without having to think about what exactly was changed at which point.
This is of course also true for the style.css