Skip to content

Instantly share code, notes, and snippets.

@d4mation
Created November 1, 2022 18:50
Show Gist options
  • Save d4mation/90e44828f2322a9ea8ab7e25f804c71f to your computer and use it in GitHub Desktop.
Save d4mation/90e44828f2322a9ea8ab7e25f804c71f to your computer and use it in GitHub Desktop.
Populate EDD Advanced Reporting with data for every Download
// Just run this in the console and you're good to go
var firstOption = true;
jQuery( 'select[name="edd_report_series[0][download]"] option' ).each( function( index, option ) {
if ( jQuery( option ).val() == 0 || jQuery( option ).val() == 'all' ) return true;
if ( firstOption ) {
var $row = jQuery( option ).closest( '.eddar-collection-row' );
firstOption = false;
}
else {
jQuery( '.eddar-collection-add-row' ).click();
var $row = jQuery( '.eddar-collection-row' ).last();
}
$row.find( 'select[name*="context"]' ).val( 'earnings_gross' ).trigger( 'change' );
$row.find( 'select[name*="download"]' ).val( jQuery( option ).val() ).trigger( 'change' ).trigger( 'chosen:updated' );
$row.find( 'select[name*="status"]' ).val( 'complete' ).trigger( 'change' );
jQuery( '.eddar-collection-add-row' ).click();
$row = jQuery( '.eddar-collection-row' ).last();
$row.find( 'select[name*="context"]' ).val( 'earnings_gross' ).trigger( 'change' );
$row.find( 'select[name*="download"]' ).val( jQuery( option ).val() ).trigger( 'change' ).trigger( 'chosen:updated' );
$row.find( 'select[name*="status"]' ).val( 'edd_subscription' ).trigger( 'change' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment