WooCommerce Customer/Order CSV Export - Auto-export only orders with subscriptions or renewals
<?php // only copy this line if needed
function sv_wc_customer_order_csv_auto_export_subscriptions_renewals_only( $order_ids ) {
if ( defined( 'DOING_CRON' ) && DOING_CRON && function_exists( 'wcs_order_contains_subscription' ) ) {
$subscriptions = $renewals = array();
$subscriptions = array_filter( $order_ids, 'wcs_order_contains_subscription' );
$renewals = array_filter( $order_ids, 'wcs_order_contains_renewal' );
$order_ids = array_merge( $subscriptions, $renewals );
}
return $order_ids;
}
add_filter( 'wc_customer_order_csv_export_ids', 'sv_wc_customer_order_csv_auto_export_subscriptions_renewals_only' );