Execute a function after confirmed purchase status

1

Well, I have an e-commerce in my hands using CMS WordPress + WooCommerce + PagSeguro (Claudio Sanches Version) and would like to make a change in the DB after the purchase is confirmed.

This change would be simple, just swapping a field inside the user.

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

Does anyone know a solution?

    
asked by anonymous 09.09.2016 / 15:41

1 answer

4

You are looking for a Action , especially woocommerce_payment_complete . Here you find an (extensive) list with all the hooks that or woocommerce provides.

Basically, you create a action of type

add_action( 'woocommerce_payment_complete','meu_metodo' );

and obviously creates your method

function meu_metodo(){
    # code...
}

and your meu_metodo() method will run every time this action (full payment) happens. Here has an article that details a little more about actions which can happen next to the payment.

    
09.09.2016 / 15:50