You need start any action only payment is confirmed? If yes, this post will help you. This a simple but very efficient snippet.
How to create action after payment confirmed on WooCommerce?
Snippet to start specific function after payment is confirmed on WooCommerce. In this example, after payment is confirmed set the new value to user.
function checkPayment ($order_id) { ///get the order $order = new WC_Order($order_id); $user_id = $order->get_user_id(); ///check for set info update_user_meta( $user_id, 'field_name', 'field_value' ); } add_action( 'woocommerce_payment_complete', 'checkPayment' );
Important
This Snippet requires the payment method to call woocommerce_payment_complete() / $order->payment_complete(). Most payment methods do this already because is default on woocommerce payment method.
Do you like the post? Please, leave your comment!
3 Responses
Good afternoo Edurado
i am in Tanzania and need some help
we have a WordPress website
https://inbox.co.tz
we want to use WhatsApp to take orders and communicate
as the website is too complicated and the users are finding it challenging
thanks
Olá Eduardo, tudo bom? Estou montando um site em que a pessoa faz uma doação e ganha um número da sorte a cada R$ 50 doados. Após efetuar a doação ela precisa escolher qual produto será doado (2 opções) e qual instituição irá receber aquele produto (2 opções).
É possível fazer esse fluxo a partir desse snippet que você postou?
Obrigado,
Abraços
Muito bom, parabéns!