Service/OrderElementManager.php
public function countProductQuantity(BaseOrder $order, ProductInterface $product)
    {
        foreach ($order->getOrderElements() as $orderElement) {
            if ($orderElement->getProduct()->getId() === $product->getId()) {
                return $orderElement->getQuantity();
            }
        }

        return 0;
    }
public function countProductQuantity(BaseOrder $order, ProductInterface $product)
    {
        foreach ($order->getOrderElements() as $orderElement) {
            if ($orderElement->getProduct()->getId() === $product->getId()) {
                return $orderElement->getQuantity();
            }
        }

        return 0;
    }
@param BaseOrder        $order
@param ProductInterface $product

@return int