Ein Kunde möchte die Rechnungsnummer in der Admin Spalte sehen. Das klappt leider nicht von Haus aus mit WooCommerce Germanized* Plugin. Aber mit diesem kleinen Snippet ist das ohne Probleme möglich. Das Snippet in die function.php schreiben oder via Snippet Tool.
// Add custom column to order table
add_filter( 'manage_shop_order_posts_columns', 'add_invoice_number_column_to_orders_table', 20 );
function add_invoice_number_column_to_orders_table( $columns ) {
// Find the position of the "Order Number" column
$order_number_column = array_search( 'order_number', array_keys( $columns ) );
// Insert "Invoice Number" column after "Order Number" column
$new_columns = array_slice( $columns, 0, $order_number_column + 1, true ) +
array( 'invoice_number' => __('Rechnungsnummer', 'your-text-domain') ) +
array_slice( $columns, $order_number_column + 1, null, true );
return $new_columns;
}
// Display custom column data in order table
add_action( 'manage_shop_order_posts_custom_column', 'display_invoice_number_in_orders_table', 99 );
function display_invoice_number_in_orders_table( $column ) {
global $post;
// Check if Germanized is active
if ( class_exists( 'WC_GZDP_Invoice' ) && $column === 'invoice_number' ) {
// Get the order ID
$order_id = $post->ID;
// Get the invoices for the order
$invoices = wc_gzdp_get_invoices_by_order( wc_get_order( $order_id ), 'simple' );
// Check if there is at least one invoice
//var_dump($invoices);
if ( count( $invoices ) > 0 ) {
// Get the formatted number of the first invoice
//$invoices[0]->document->formatted_number
foreach( $invoices as $invoice ) {
echo ($invoice->formatted_number);
}
} else {
echo "N/A";
}
}
}
vielen dank auch an purin.at