Update User Meta After a Successful Order in WooCommerce

As seen on Rodolfo’s Business Bloomer website.

add_action( 'woocommerce_thankyou', 'bbloomer_checkout_save_user_meta');
 
function bbloomer_checkout_save_user_meta( $order_id ) {
     
    $order = new WC_Order( $order_id );
    $user_id = $order->get_user_id();
     
    if ( $order->get_total() > 100 ) {  // Define your condition here
        update_user_meta( $user_id, 'custom_checkbox', 'on');
    }
 
}

Revisions

Tags:

No comments yet.

Leave a Reply