How To Modify WooCommerce
Like WordPress itself, WooCommerce requires regular new feature and security updates. Those updates overwrite all the previous coding and that any changes you have made directly to WooCommerce are lost after the update. But there is a way to go about code customization without losing everything when you update. See WordPress Customization for more information.
Hooks allow you to create your own coding independent of the core WooCommerce coding. See this page for more information about hooks, WordPress Customization
WooCommerce has tons of action and filter hooks. Click this link for a list of WooCommerce hooks, https://woocommerce.github.io/code-reference/hooks/hooks.html
Your custom coding, like in the example below, can be placed in the functions.php file of a child theme or in its own plugin. Here is a link to the WordPress plugin documentation, https://developer.wordpress.org/plugins/intro/
Here's an example of a WooCommerce action hook:
/**
* Add an order note to the WooCommerce admin order
*/
function 1dd_woocommerce_thankyou( $order_id ) {
$order->add_order_note('Hold If Backordered' );
}
add_action('woocommerce_thankyou', '1dd_woocommerce_thankyou', 10, 1);
This action uses a WooCommerce predefined hook called 'woocommerce_thankyou'
. That action hook allows you to add an admin order note, a custom message or some special functionality to the “thank you” page that appears after a customer has completed their order. In this case, 'Hold If Backordered'
is added as a note the admin order view.
This code: 'add_action('woocommerce_thankyou', '1dd_woocommerce_thankyou', 10, 1);
' tells WooCommerce to use the function called '1dd_woocommerce_thankyou
' after WooCommerce processes the order.