Last active
January 27, 2026 15:59
-
-
Save razajahangir/6d241e2e780105632122f52eb7c58d9b to your computer and use it in GitHub Desktop.
HPOS-compatible SQL query to export active and canceled subscriptions in WooCommerce.
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
| -- Export Active and Canceled Subscriptions (HPOS Compatible) | |
| -- Adjust the table prefix 'wp_' if your database uses a different one, though 'wp_' was detected in wp-config.php. | |
| SELECT | |
| o.id AS subscription_id, | |
| o.status AS subscription_status, | |
| o.date_created_gmt AS date_created, | |
| a.first_name, | |
| a.last_name, | |
| a.email, | |
| o.total_amount, | |
| o.currency | |
| FROM | |
| wp_wc_orders o | |
| INNER JOIN | |
| wp_wc_order_addresses a ON o.id = a.order_id | |
| WHERE | |
| o.type = 'shop_subscription' | |
| AND o.status IN ('wc-active', 'wc-cancelled') | |
| AND a.address_type = 'billing' | |
| ORDER BY | |
| o.id DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment