Advertisement
geminilabs

Export Woocommerce reviews for Site Reviews import

Mar 17th, 2022 (edited)
1,256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MySQL Query to export all Woocommerce reviews to a CSV file which can then be imported into Site Reviews
  2.  
  3. -- 1. Install the [Database Browser](https://wordpress.org/plugins/database-browser/) plugin
  4. -- 2. Go to the "Tools > Database Browser" page
  5. -- 3. Click the "Select table" button (it doesn’t matter which table is selected)
  6. -- 4. Copy the table prefix of your tables (for example, if the table is `wp_posts`, the prefix is the first part with the underscore `wp_`).
  7. -- 5. Click the "Edit query" button
  8. -- 6. Paste the SQL query, replacing every instance of `wp_` in the SQL query with your table prefix.
  9. -- 7. Click the "Run query" button
  10. -- 8. Click the "CSV" button to download the results
  11.  
  12. SELECT
  13.     c.comment_date as date,
  14.     c.comment_date_gmt as date_gmt,
  15.     cm.meta_value as rating,
  16.     c.comment_content as content,
  17.     c.comment_author as name,
  18.     c.comment_author_email as email,
  19.     c.comment_author_IP as ip_address,
  20.     c.comment_approved as is_approved,
  21.     c.comment_post_ID as assigned_posts,
  22.     c.user_id as user_id
  23. FROM wp_comments AS c
  24. INNER JOIN wp_commentmeta AS cm ON c.comment_ID = cm.comment_id
  25. WHERE 1=1
  26. AND c.comment_type = 'review'
  27. AND cm.meta_key = 'rating'
  28. AND cm.meta_value IS NOT NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement