I need to do an action when an order is completed.
I Have tried this:
function mysite_woocommerce_payment_complete( $order_id ) {
error_log("callback fired");
}
add_action( 'woocommerce_payment_complete', 'mysite_woocommerce_payment_complete' );
But when I use the checkmark to mark the order as completed here in admin orders screen,
...the hook doesn't fire.
I tried woocommerce_order_status_changed
too, it does the action when I place the order, but does nothing when i mark the order completed.
But when I mark the order completed, I get the email about completing it.
Thanks!
Edit:
I tried woocommerce_order_status_changed
too, this way:
function mysite_woocommerce_payment_complete($order_id, $old_status, $new_status ) {
error_log("$old_status / $new_status
");
}
add_action( 'woocommerce_order_status_changed', 'mysite_woocommerce_payment_complete', 99, 3 );
but it fires on purchasing (I selected bank transfer) and shows: "pending / on-hold", but not true - see edi2 doesn't fire on manual backend change from "on hold" to "completed". Neither by checkmark nor in single order interface.
Edit2
woocommerce_order_status_changed
and woocommerce_order_status_completed
works, it only outputed my testing "error" into debug.log, not to error_log for some reason.
The woocommerce_payment_complete
i used previously doesn't apply to methods like bank transfer, that's why that didn't work. Thanks to @helgatheviking for the quick and right answer