WooCommerce payment complete hook

后端 未结 3 1006
忘了有多久
忘了有多久 2020-11-29 03:56

After a long search, I found this post:

WooCommerce hook for "after payment complete" actions

which talks about creating web hooks in WooCommerce t

3条回答
  •  情深已故
    2020-11-29 04:41

    The woocommerce_payment_complete hook is fired when the payment is completed. The only variable passed is the order id, though from that you can get the order object, and ultimately the user.

    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
        }
    }
    

提交回复
热议问题