WooCommerce is the world leading e-commerce platform and has a hidden away setting that fixes this problem. I'm sharing this in case anyone else finds it useful.
By default, anyone can leave a product review on a WooCommerce website. The plugin doesn't check who is leaving the review or whether they have actually purchased the product.
This is sometimes beneficial. For example if your products are also available for sale elsewhere then you're likely to get more reviews if you let people review them who didn't purchase directly on your website.
However some store owners have a problem with reviews from people who haven't purchased the product at all - for example non-buyers who just like the look of a product, or malicious reviews from competitors. (This is a separate issue to spam reviews, which can be dealt with using an anti-spam plugin.) Irrelevant reviews like this will make your genuine reviews less credible and can damage your sales if they are negative.
How to prevent non-buyers from reviewing your WooCommerce products
You'll see a tick box called 'Only allow reviews fro "verified owners". If you tick this box, only logged in users who have purchased the product will be able to leave a review.
Non-buyers will see a note saying "Only logged in customers who have purchased this product may leave a review". Problem solved!
You can read more about WooCommerce settings in the official documentation.