Created
May 23, 2021 13:15
-
-
Save wecreatedigital/f52c2c8a897276d13a72c6bb2bdccb0e to your computer and use it in GitHub Desktop.
SQL to export WooCommerce reviews
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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