Woocommerce - Call custom function after payment is completed
looks like you need add accepted_args on last parameters,Try this :
add_action( 'woocommerce_thankyou', 'your_func', 10, 1 );function your_func($order_id) { $order = new WC_Order( $order_id ); /* Do Something with order ID */}
Maybe try one of the following.
- woocommerce_checkout_order_processed
- woocommerce_new_order
add_action( 'woocommerce_subscription_payment_complete', 'YourFunction', 1, 2); function YourFunction ($order_id) { $order = new WC_Order( $order_id ); wp_mail( 'sagarseth9@example.com',' Woocommmerce Order ID is '.$order_id , 'Woocommerce order' ); }
The add_action call must be placed at the very beginning of your plugin, if using wordpress, or if a theme, in functions.php.