I have an e-commerce website on Wordpress and WooCommerce.
I Would like use some custom function when order is completed.
How can I use my function on order completed status?
Thanks
You can use a custom function hooked in woocommerce_order_status_completed
hook, this way:
add_action( 'woocommerce_order_status_completed', 'custom_wc_order_complete', 10, 2 );
function custom_wc_order_complete( $order_id, $order ) {
// Here comes your code (doing something), optionally using the $order_id argument
}
This function will be triggered when the order status will become "completed" for a specific $order_id
(argument).
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
See this related answers: