renumerate_invoices( $the_invoice_type, $the_start_number, $the_start_date, $the_end_date, $the_order_statuses, $the_delete_all ); $result_message = '

' . __( 'Invoices successfully renumerated!', 'woocommerce-jetpack' ) . '

'; } else { $result_message = '

' . __( 'Please select at least one order status.', 'woocommerce-jetpack' ) . '

'; } } ?>

Settings > Booster > PDF Invoicing & Packing Slips > Numbering.', 'woocommerce-jetpack' ); ?>

', '' . __( 'Date to start renumerating. Leave blank to renumerate all invoices.', 'woocommerce-jetpack' ) . '', ); // End Date $data[] = array( __( 'End Date', 'woocommerce-jetpack' ), '', '' . __( 'Date to end renumerating. Leave blank to renumerate all invoices.', 'woocommerce-jetpack' ) . '', ); // Number $data[] = array( __( 'Start Number', 'woocommerce-jetpack' ), '', '' . __( 'Counter to start renumerating. Leave 0 to continue from current counter.', 'woocommerce-jetpack' ) . '', ); // Delete All $data[] = array( __( 'Delete All', 'woocommerce-jetpack' ), '' . ' ' . '', '', ); // Type $invoice_type_select_html = ''; $data[] = array( __( 'Document Type', 'woocommerce-jetpack' ), $invoice_type_select_html, '', ); // Statuses $order_statuses_select_html = ''; $data[] = array( __( 'Order Statuses', 'woocommerce-jetpack' ), $order_statuses_select_html, '', ); // Button $data[] = array( '', '', '' ); // Print all echo wcj_get_table_html( $data, array( 'table_class' => 'widefat striped', 'table_heading_type' => 'vertical', ) ); ?>

' . __( 'Results', 'woocommerce-jetpack' ) . ''; echo '

' . $renumerate_result . '

'; } ?>
$start_date, 'inclusive' => true, ), ); if ( '' != $end_date ) { $date_query_array[0]['before'] = $end_date; } $deleted_invoices_counter = 0; $created_invoices_counter = 0; $offset = 0; $block_size = 96; while( true ) { $args = array( 'post_type' => 'shop_order', 'post_status' => 'any', 'posts_per_page' => $block_size, 'offset' => $offset, 'orderby' => 'date', 'order' => 'ASC', 'date_query' => $date_query_array, ); $loop = new WP_Query( $args ); if ( ! $loop->have_posts() ) { break; } while ( $loop->have_posts() ) : $loop->the_post(); $order_id = $loop->post->ID; if ( in_array( $loop->post->post_status, $order_statuses ) && strtotime( $loop->post->post_date ) >= strtotime( $start_date ) && ( strtotime( $loop->post->post_date ) <= strtotime( $end_date ) || '' == $end_date ) ) { $the_order = wc_get_order( $order_id ); if ( 0 != $the_order->get_total() ) { wcj_create_invoice( $order_id, $invoice_type, strtotime( $loop->post->post_date ) ); $created_invoices_counter++; } } else { if ( $the_delete_all && wcj_is_invoice_created( $order_id, $invoice_type ) ) { wcj_delete_invoice( $order_id, $invoice_type ); $deleted_invoices_counter++; } } endwhile; $offset += $block_size; } $output .= '

' . sprintf( __( 'Total documents created: %d', 'woocommerce-jetpack' ), $created_invoices_counter ) . '

'; $output .= '

' . sprintf( __( 'Total documents deleted: %d', 'woocommerce-jetpack' ), $deleted_invoices_counter ) . '

'; return $output; } } endif; return new WCJ_PDF_Invoicing_Renumerate_Tool();