Run a function after purchase status confirmed

Asked

Viewed 328 times

1

Guys, I’m with an e-commerce in hand using the CMS Wordpress + Woocommerce + Pagseguro(Version of Claudio Sanches) and would like to perform a change in the bd after the purchase is confirmed.

This change would be simple, only change a field within the user.

In short, I currently need to find out if there is any Woocommerce function that runs after the purchase is confirmed. (In this case my product is digital)

Someone knows a solution?

1 answer

5


You’re looking for a Action, in particular the woocommerce_payment_complete. Here you find a (extensive) list of all Hooks that Woocommerce makes available.

Basically, you create a action of the kind

add_action( 'woocommerce_payment_complete','meu_metodo' );

and obviously creates its method

function meu_metodo(){
    # code...
}

and its method meu_metodo() will be executed every time this action (full payment) happens. Here has an article that details a little more about actions that can happen along with payment.

  • 1

    I’m even speechless to thank you man! Hahaha, thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.