I am using the woocommerce_new_order_item
hook in my functions.php file.
The code I have is:
add_action( 'woocommerce_new_order_item', 'wc_order_item_added', 1, 1 );
function wc_order_item_added($item_id, $item, $order_id) {
global $mysqli;
//$order = new WC_Order( $item_id );
$sql = $mysqli->query("INSERT into a_test (one) values ('".$item_id."');");
}
Which I found from: http://hookr.io/actions/woocommerce_new_order_item/
But the $order_id
variable is not being returned. The only variable that is working is, $item_id
Change the action to this
The last parameter is number of variables that the callback accepts