0

I wanted to add a functionality like calling an SQL procedure after a checkout transaction completed successfully. I tried searching for documentation but I can't seem to find it.

jestrange
  • 271
  • 3
  • 15

2 Answers2

0

seful action is woocommerce_payment_complete, called after the payment has been taken for an order. This is useful if you want to perform some automated task after payment has been taken:

add_action( 'woocommerce_payment_complete', 'so_payment_complete' );
function so_payment_complete( $order_id ){
    $order = wc_get_order( $order_id );
    $user = $order->get_user();
    if( $user ){
       // do something with the user
   }
}

Find more on this. URL

Hope this will helps you.

Sunil Dora
  • 1,407
  • 1
  • 13
  • 26
0

Hook in to the woocommerce_payment_complete_order_status filter, which denotes a successful payment.

<?php


add_action('woocommerce_payment_complete_order_status', 'function_to_run' );

function function_to_run($order_id) {
    $order = new WC_Order( $order_id );


   //Rest of your code

}
Masivuye Cokile
  • 4,754
  • 3
  • 19
  • 34