Exporting WooCommerce reviews can help you analyse customer feedback, display reviews on external platforms, or keep a backup of valuable customer data. While plugins are available to simplify this process, exporting reviews manually using custom code offers more flexibility and reduces plugin dependency.
In this guide, we’ll walk you through how to export WooCommerce product reviews as a CSV or XML file without using a plugin.
Why Export WooCommerce Reviews?
Here are a few key reasons to export product reviews:
- Backup Customer Feedback: Safeguard reviews from data loss by keeping a backup.
- Analyse Customer Sentiment: Use reviews to understand customer satisfaction and improve your offerings.
- Display on External Platforms: Share reviews on other websites, marketplaces, or social media.
Step 1: Export WooCommerce Reviews as a CSV
The following code allows you to generate and download a CSV file containing product reviews. Add this code to your theme’s functions.php file or in a child theme.
/* Snippet: How to Export WooCommerce Reviews Without a Plugin – 2025
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1615
* Tested with WooCommerce 9.3.3
* “This function exports WooCommerce reviews as a CSV file”
*/
function wcsuccess_export_reviews_to_csv() {
if ( isset( $_GET[‘export_reviews’] ) ) {
global $wpdb;$reviews = $wpdb->get_results( “
SELECT comment_post_ID, comment_author, comment_content, comment_date, comment_approved
FROM {$wpdb->comments}
WHERE comment_type = ‘review’
” );header( ‘Content-Type: text/csv’ );
header( ‘Content-Disposition: attachment;filename=reviews.csv’ );$output = fopen( ‘php://output’, ‘w’ );
fputcsv( $output, array( ‘Product ID’, ‘Author’, ‘Review’, ‘Date’, ‘Approved’ ) );foreach ( $reviews as $review ) {
fputcsv( $output, array(
$review->comment_post_ID,
$review->comment_author,
$review->comment_content,
$review->comment_date,
$review->comment_approved ? ‘Yes’ : ‘No’,
));
}fclose( $output );
exit;
}
}
add_action( ‘admin_init’, ‘wcsuccess_export_reviews_to_csv’ );
How This Works
- SQL Query: Retrieves WooCommerce product reviews from the database.
- CSV Output: The reviews are formatted into a CSV file and downloaded automatically.
To trigger the export, navigate to: https://yourwebsite.com/wp-admin/?export_reviews
Step 2: Export WooCommerce Reviews as XML
If you need to export reviews in XML format, use the following code:
/* Snippet: How to Export WooCommerce Reviews Without a Plugin – 2025
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1615
* Tested with WooCommerce 9.3.3
* “This function exports WooCommerce reviews as an XML file”
*/
function wcsuccess_export_reviews_to_xml() {
if ( isset( $_GET[‘export_reviews_xml’] ) ) {
global $wpdb;$reviews = $wpdb->get_results( “
SELECT comment_post_ID, comment_author, comment_content, comment_date, comment_approved
FROM {$wpdb->comments}
WHERE comment_type = ‘review’
” );header( ‘Content-Type: text/xml’ );
header( ‘Content-Disposition: attachment;filename=reviews.xml’ );$xml = new SimpleXMLElement( ” );foreach ( $reviews as $review ) {
$review_xml = $xml->addChild( ‘Review’ );
$review_xml->addChild( ‘ProductID’, $review->comment_post_ID );
$review_xml->addChild( ‘Author’, $review->comment_author );
$review_xml->addChild( ‘Content’, htmlspecialchars( $review->comment_content ) );
$review_xml->addChild( ‘Date’, $review->comment_date );
$review_xml->addChild( ‘Approved’, $review->comment_approved ? ‘Yes’ : ‘No’ );
}echo $xml->asXML();
exit;
}
}
add_action( ‘admin_init’, ‘wcsuccess_export_reviews_to_xml’ );
How This Works
- XML Generation: The code retrieves reviews from the database and generates an XML file for download.
To trigger the export, navigate to: https://yourwebsite.com/wp-admin/?export_reviews_xml
Step 3: Add Export Links to the WooCommerce Admin Dashboard
For easy access, you can add export links directly to the WooCommerce admin dashboard.
/* Snippet: How to Export WooCommerce Reviews Without a Plugin
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1615
* Tested with WooCommerce 9.3.3
* “This function adds export links to the WooCommerce dashboard”
*/
function wcsuccess_add_reviews_export_links() {
echo ‘Export Reviews (CSV)‘;
echo ‘Export Reviews (XML)‘;
}
add_action( ‘woocommerce_reports_sidebar’, ‘wcsuccess_add_reviews_export_links’ );
Best Use Cases for Exporting Reviews
- Monitor Customer Feedback: Analyse reviews to gain insights and make informed business decisions.
- Backup Data: Protect customer reviews from data loss.
- Promote Positive Reviews: Share customer reviews on social media or product pages to build trust.
Conclusion
Exporting WooCommerce reviews as CSV or XML without a plugin allows you to keep control over your data and avoid unnecessary dependencies. Whether for analysis, backups, or promotion, exporting reviews manually ensures you have access to valuable customer feedback.
Test these customizations in a staging environment before applying them to your live site. Use a child theme to protect your changes from theme updates. For more customizations, explore our wp-config generator for additional configuration options.
This guide perfectly complements our guide on how to import WooCommerce reviews without a plugin