Skip to content

Commit

Permalink
New: add Invoice Number column to the orders export of WooCommerce An…
Browse files Browse the repository at this point in the history
…alytic (#597)
  • Loading branch information
MohamadNateqi authored Sep 4, 2023
1 parent 44c0ee4 commit 600d40e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions includes/class-wcpdf-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function __construct() {
// document actions
add_action( 'wpo_wcpdf_document_actions', array( $this, 'add_regenerate_document_button' ) );

// add "invoice number" column to WooCommerce Analytic - Orders
add_filter( 'woocommerce_rest_prepare_report_orders', array( $this, 'add_invoice_number_to_order_report' ) );
add_filter( 'woocommerce_report_orders_export_columns', array( $this, 'add_invoice_number_header_to_order_export' ) );
add_filter( 'woocommerce_report_orders_prepare_export_item', array( $this, 'add_invoice_number_value_to_order_export' ), 10, 2 );
}

// display review admin notice after 100 pdf downloads
Expand Down Expand Up @@ -1214,6 +1217,20 @@ public function add_invoice_number_to_order_report( $response ) {

return $response;
}

public function add_invoice_number_header_to_order_export( $export_columns ) {
$export_columns['invoice_number'] = __( 'Invoice Number', 'woocommerce-pdf-invoices-packing-slips' );

return $export_columns;
}

public function add_invoice_number_value_to_order_export( $export_item, $item ) {
if ( ! empty( $item['invoice_number'] ) ) {
$export_item['invoice_number'] = $item['invoice_number'];
}

return $export_item;
}
}

endif; // class_exists

0 comments on commit 600d40e

Please sign in to comment.