skip to Main Content

Get the user ID on woocommerce_order_status_completed hook

I write function: add_action( 'woocommerce_order_status_completed', 'order_completed'); function order_completed($order_id) { $user_id = $order->get_user_id(); // or $order->get_customer_id(); $order = wc_get_order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item->get_name(); } switch ($product_name) { case 'FREE': update_user_meta($user_id,…

VIEW QUESTION
Back To Top
Search