Trying to “add_action” to “create_order” function in Woocommerce/WordPress

I’m trying to hook into the WooCommerce function that creates orders create_order or wc_create_order – and pull some of the variables from it. I’ve hooked into functions before, but they’ve never been this complicated. The functions are inside the WC_Checkout Class – and I can’t seem to find the right tool to get over that wall.

The code inside the function is irrelevant at this point in time. I just want the function to fire. I’ve tried the basic add_action function.

Read More
add_action( 'create_order', 'my_function', 1, 1 );

I also tried a few more options that were a little complicated, but the resources for this were a little sketch. I’m pretty sure it’s more complicated than this too:

function init() {

    add_action('create_order', array(&$this, 'my_function'), 1, 1 );

}

I’ve seen some posts including __construct() but they weren’t specific enough to work.

Related posts