Skip to content

Instantly share code, notes, and snippets.

View razajahangir's full-sized avatar
🎯
Focusing

Raza Jahangir razajahangir

🎯
Focusing
View GitHub Profile
@razajahangir
razajahangir / export-active-and-canceled-subscriptions.sql
Last active January 27, 2026 15:59
HPOS-compatible SQL query to export active and canceled subscriptions in WooCommerce.
-- 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,
@razajahangir
razajahangir / export-wc-hpos-orders-sql.sql
Last active January 27, 2026 08:58
Advanced SQL query to export WooCommerce orders (Date, Email, Products, Coupons) from HPOS-enabled tables (wp_wc_orders) by joining with legacy item tables. Optimized for reporting.
SELECT
o.id AS Order_ID,
o.status AS Order_Status, -- Added Order Status here
o.date_created_gmt AS Order_Date,
a.email AS Billing_Email,
(
SELECT GROUP_CONCAT(order_item_name SEPARATOR ' | ')
FROM wp_woocommerce_order_items oi
WHERE oi.order_id = o.id
AND oi.order_item_type = 'line_item'