Home » Wordpress » WordPress with WooCommerce add_actions not working

WordPress with WooCommerce add_actions not working

Posted by: admin November 30, 2017 Leave a comment

Questions:

I’m trying to add a function (hook) after payment is completed in WordPress where i use the plugin woocomerce.

The documentation for woocommere says that there is an action called “woocommerce_payment_complete” and a filter called “woocommerce_payment_complete_order_status”

Nothing is happend, when i try to use them

add_action('woocommerce_payment_complete', 'do_something_foo');

function do_something_foo() {
    wp_die("foo!");

}

Why doesn’t it work ?

Thanks !

Answers:

In my experience around woocommerce I’ve always had much more success hooking the order status action, perhaps this is a viable alternative for your solution?

add_action( 'woocommerce_order_status_completed', 'do_something_foo' );

   function do_something_foo() {
   wp_die("foo!");

}