How to get the particular product quantity in orders in Woocommerce [closed]

In the foreach you need to check each item for its product id and compare it to the targeted id

$order = new WC_Order($order_id);

$item_quantity = 0;
$targeted_id = 14988;

foreach ($order->get_items() as $item_id => $item) {
    // check if current item (product) id is equal to targeted id
    if ($item->get_product_id() == $targeted_id) {
        $item_quantity += $item->get_quantity();
        // once the correct cart item is found we no longer need to loop all other products so we break out of the loop
        break;
    }
}