// Add new columns to the “My Orders” table in the account dashboard.
add_filter( ‘woocommerce_my_account_my_orders_columns’, ‘add_custom_my_account_orders_columns’, 10, 1 );
function add_custom_my_account_orders_columns( $columns ) {
$columns[‘order_products’] = ‘Order Product’; // Add new column for Order Product
$columns[‘payment_method_title’] = ‘Payment Method Title’; // Add new column for Payment Method Title
return $columns;
}
// Add data for the “Order Product” column.
add_action( ‘woocommerce_my_account_my_orders_column_order_products’, ‘add_order_products_to_orders_column’, 10, 1 );
function add_order_products_to_orders_column( $order ) {
$items = $order->get_items();
foreach ( $items as $item ) {
echo esc_html( $item->get_name() ) . ‘
‘;
}
}
// Add data for the “Payment Method Title” column.
add_action( ‘woocommerce_my_account_my_orders_column_payment_method_title’, ‘add_payment_method_to_orders_column’, 10, 1 );
function add_payment_method_to_orders_column( $order ) {
echo esc_html( $order->get_payment_method_title() );
}
add_action( ‘woocommerce_before_order_itemmeta’, ‘so_before_order_itemmeta’, 10, 3 );
function so_before_order_itemmeta( $item_id, $item, $_product ){
echo get_the_term_list( $_product->id, ‘product_cat’, __( ‘Categories:’, ‘textdomain’ ), ‘,’, ” );
}