Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wecreatedigital/f52c2c8a897276d13a72c6bb2bdccb0e to your computer and use it in GitHub Desktop.
Save wecreatedigital/f52c2c8a897276d13a72c6bb2bdccb0e to your computer and use it in GitHub Desktop.
SQL to export WooCommerce reviews
# Based on https://deanandrews.uk/export-woocommerce-reviews-wordpress/ but enhanced to include the rating and filter out other comments.
```
SELECT `post_title` AS 'Product', `comment_author` AS 'Customer Name', `comment_author_email` AS 'Customer Email', `comment_date`, `comment_content` AS 'Review', `wp_commentmeta`.`meta_value` AS 'Rating'
FROM `wp_comments`
INNER JOIN `wp_posts` ON `comment_post_ID`=`ID`
INNER JOIN `wp_commentmeta` ON `wp_commentmeta`.`comment_id`=`wp_comments`.`comment_ID`
WHERE `comment_author` != 'WooCommerce'
AND `wp_posts`.`post_type` = 'product'
AND `wp_posts`.`post_status` = 'publish'
AND `comment_approved` = '1'
AND `wp_commentmeta`.`meta_key` = 'rating'
GROUP BY `wp_commentmeta`.`comment_id`
ORDER BY `Rating` ASC
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment