I am trying to change the columns in the orders overview (orders.php) in the Woocommerce My Account page. I got this working now but now it is changed in the quotes overview (quotes.php) as well.
Any ideas how to change the columns only in the orders overview?
This is what I did so far and what works well for the orders overview.
In the functions.php
add_filter( 'woocommerce_account_orders_columns', 'new_orders_columns' );
function new_orders_columns( $columns = array() ) {
// Unsets the columns which you want to hide
unset( $columns['order-total'] );
unset( $columns['order-number'] );
unset( $columns['order-date'] );
unset( $columns['order-status'] );
unset( $columns['order-total'] );
unset( $columns['order-actions'] );
// Add new columns
$columns['rechnungsnummer'] = __( 'Rechnung', 'woocommerce' );
$columns['order-date'] = __( 'Rechnungsdatum', 'woocommerce' );
$columns['order-status'] = __( 'Status', 'woocommerce' );
$columns['lieferdatum'] = __( 'Voraussichtliches Lieferdatum', 'woocommerce' );
$columns['tracking'] = __( 'Tracking', 'woocommerce' );
return $columns;
}
In the orders.php
<?php elseif ( 'tracking' === $column_id ) : ?>
<?php
$sendungsverfolgung_custom_field = get_post_meta($order->get_id(), 'rechnung_link', true);
if ($sendungsverfolgung_custom_field == true) {
echo '<a href="' . esc_html( get_post_meta($order->get_id(), 'rechnung_link', true)) . '" class="woocommerce-button button" target="_blank">Sendung verfolgen</a>';
} else {
echo "Folgt in Kürze";
}
?>
<?php elseif ( 'rechnungsnummer' === $column_id ) : ?>
<?php
echo esc_html( get_post_meta($order->get_id(), 'rechnungsnummer', true));
?>
<?php elseif ( 'lieferdatum' === $column_id ) : ?>
<?php
echo esc_html( get_post_meta($order->get_id(), 'lieferdatum', true));
?>