Job a11n
(@jobthomas)
Automattic Happiness Engineer
Hi @ananddevops. First of all, adding custom PHP is something you normally can get help for from the developer who shared the custom snippet.
That said, I’d highly discourage using the Storefront functions.php file, because every time Storefront has an update, it means that your code will be disabled.
The best approach is to use a child theme. Here are the instructions on how to use that: https://docs.woocommerce.com/document/set-up-and-use-a-child-theme/
@jobthomas
Thank you for the revert.
1. Ok. Not seeking a confirmation on the PHP code. But could you clarify incase I want to make filter/hook changes to functions.php, incase of storefront theme, is that file storefront_functions.php?
2. Adding the code anywhere in the file will work? Querying specific to storefront theme?
3. I understand and child theme is a must and thats what I will eventually do. As of now I need to run a basic test(like a hello world) and see if all goes all well before I undergo the child theme exercise.
4.To my last query, will the changes reflect on save, or do I need to republish the page/restart the hosting instance/any other draft to publish change method? Again confirming specific to Storefront theme.
Thanks
Job a11n
(@jobthomas)
Automattic Happiness Engineer
1. Ok. Not seeking a confirmation on the PHP code. But could you clarify incase I want to make filter/hook changes to functions.php, incase of storefront theme, is that file storefront_functions.php?
Nope. The file needs to be functions.php in your child theme folder (or in Storefront).
2. Adding the code anywhere in the file will work? Querying specific to storefront theme?
Yup. It’ll work from top to bottom and get priority over WC core functions. (So the lower on that file the more likely it’ll display.)
3. I understand and child theme is a must and thats what I will eventually do. As of now I need to run a basic test(like a hello world) and see if all goes all well before I undergo the child theme exercise.
A child theme takes less than 10 minutes to configure (you can even find plugins to do it for you), so I won’t wait wit that.
4.To my last query, will the changes reflect on save, or do I need to republish the page/restart the hosting instance/any other draft to publish change method? Again confirming specific to Storefront theme.
As soon as you save the file and it’s in the right place, the new code will be active. There’s no such thing as a draft here.
@jobthomas
That helped.
Appreciate the help.
Thanks