M
M
makboriska2021-12-27 15:40:57
WordPress
makboriska, 2021-12-27 15:40:57

Run script after successful Woocommerce payment?

There is a website selling codes (vouchers), after payment the client should receive the same code that we receive via api, I can’t figure out a little how to do it, that’s what I have

Through the woocommerce_payment_complete hook, I run a script that makes a request to issue a key , the key comes all the best, but how can I write this key to the database so that it goes to the client by mail, so that it is on the senkyu page and in the client's personal account?

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 ){
        // тут мой скрипт по api который получает code в переменную $code
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question