I am trying to send a XML-mail to a stock when a purchase is completed in Woocommerce.
I've read about adding an action to: woocommerce_payment_complete
in this thread.
The basic code is here and is almost working as it should.
add_action( 'woocommerce_payment_complete', 'it_mail_to_dafolo' );
function it_mail_to_dafolo( $order_id ){
$to = 'some_mail@gmail.com';
$subject = 'test';
$message = '<Ordre>';
$message .= '</Ordre>';
wp_mail( $to, $subject, $message );
var_dump("Hello?");
}
But: Nothing is showed by the var_dump("Hello?")
My problem is: I want to add product attributes and different data to the mail, and this is something with a lot of debugging and testing.
I've started, but the workflow of testing a purchase and checking your mail every time you want to check if something was done correct is terrifying.
What i have tried:
I've tested the amazing plugin: Debug Toolkit and some others, but none of them are working with this hook. They are working other places in my function.php and on my site perfectly.
Also: i've tried with different payment solution, and the problem is, that i have to 'complete a purchase', so i can't debug with the paying solution like bank transfer. Then the function is not called. So i have to set up a test pay like Bambora - (a danish plugin like Stripe). There is a lot of redirections going on, as you all may know. Maybe it has something to do with that.
I've also read about die()
and tried with that after var_dump()
, to exits the program’s execution, but still nothing.
I've found that you can export to your error_log from this thread - but is it really the best WordPress has to offer?