Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tamarazuk/1bde8adecb05934e967a to your computer and use it in GitHub Desktop.
Save tamarazuk/1bde8adecb05934e967a to your computer and use it in GitHub Desktop.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment