Answer the question
In order to leave comments, you need to log in
How to show purchased items in Woocommerce?
There is an online store where keys are sold (they come via api) and you need to make sure that in the order history there is a history of purchased GOODS, not orders, i.e. by default, wc shows us orders in which there can be 5 products, for example, how to make these 5 products be displayed instead of orders?
I decided to do it by deleting / adding columns to the order history
add_filter( 'woocommerce_my_account_my_orders_columns', 'additional_my_account_orders_column', 10, 3 );
function additional_my_account_orders_column( $columns ) {
$new_columns = [];
foreach ( $columns as $key => $name ) {
$new_columns[ $key ] = $name;
if ( 'order-status' === $key ) {
$new_columns['order-items'] = __( 'Voucher', 'woocommerce' );
}
}
return $new_columns;
}
add_action( 'woocommerce_my_account_my_orders_column_order-items', 'additional_my_account_orders_column_content', 10, 3 );
function additional_my_account_orders_column_content( $order ) {
$details = array();
foreach( $order->get_items() as $item )
$details[] = $item->get_name();
echo count( $details ) > 0 ? implode( '<br>', $details ) : '–';
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question