If you want to get Product id from order id in Woocommerce then fetch order details.
$order = new WC_Order( $order_id ); $items = $order->get_items();
then if you loop through them, you can get all the relevant data:
foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; $product_variation_id = $item['variation_id']; }
Have any doubt, then comment here!