Home / Attachments / MemberPress: Generate All Invoices
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Generate All Invoices

Code Preview
php
<?php
function generate_bulk_invoices() {
  if( isset( $_REQUEST[ 'generate-invoices' ] ) ) {
    global $wpdb;
    $query = "SELECT id FROM {$wpdb->prefix}mepr_transactions WHERE status in ('complete', 'confirmed', 'refunded')";
    $txn_ids = $wpdb->get_results( $query );
    foreach( $txn_ids as $txn_id ) {
      $invoices = new MePdfInvoicesCtrl();
      $txn = new MeprTransaction( $txn_id->id );
      if ( $txn->id > 0 ) {
        $path = $invoices->create_receipt_pdf( $txn );
	  }
    }
    echo( '<p>Invoices generated.</p>' );
    die();
  }
}
add_action( 'admin_init', 'generate_bulk_invoices' );

Comments

Add a Comment