Why is it the preferred choice, to have WooCommerce function modifications placed inside the theme's 'function.php' file? Overtime, this would make the file rather large. I am of the understanding that it is generally better practice to have lots of well organised smaller files, rather than fewer much larger files.
With this in mind, what is wrong with copying the 'wc-template-functions.php' and 'wc-templates-hooks.php' files into your theme (whilst keeping its file hierarchy) and modifying these files accordingly?
As a side request, from a relative newbie to the WooCommerce platform, I would appreciate if I could get a 'Yes, that works' or a 'No, I have missed something out' response to my below understanding of how the WooCommerce; files, hooks, actions and templates all work with one and other
My Understanding:
- The WooCommerce functions are registered within the 'wc-template-functions.php' file. For the purpose of this explanation, I would like to refer to the
woocommerce_breadcrumbentry. - WooCommerce then uses the 'wc-templates-hooks.php' file to call the registered function by using a typical entry such as
add_action('woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0 );This simply directswoocommerce_breadcrumbto be called within thewoocommerce_before_main_contenthook. - WooCommerce is then able to output the above by placing
do_action( 'woocommerce_before_main_content' );where necessary. In this case, within all of the Template files.