How can I have an aggregate function in the WHERE clause?
You have to use a window function, which does something similar to a GROUP BY, but outpots all rows and not just the groups.

SELECT *
FROM (SELECT *,
             sum(available_count) OVER (PARTITION BY product_id) AS sum_count
      FROM j_product_store_availability psa) AS subq
WHERE onway = 0
  AND sum_count = 0
ORDER BY product_id;