Purchased Downloads Column in the EDD Orders List
Adds a column to Downloads > Orders listing what each order contains, so you can see what was sold without opening every order.
Opens WPIDE on
Code
add_filter( 'edd_payments_table_columns', function ( $columns ) {
$new = array();
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
if ( 'customer' === $key || 'email' === $key ) {
$new['wpide_items'] = 'Items';
}
}
return isset( $new['wpide_items'] ) ? $new : $new + array( 'wpide_items' => 'Items' );
} );
add_filter( 'edd_payments_table_column', function ( $value, $order_id, $column ) {
if ( 'wpide_items' !== $column || ! function_exists( 'edd_get_order_items' ) ) {
return $value;
}
$items = edd_get_order_items( array( 'order_id' => $order_id, 'number' => 6 ) );
$names = array();
foreach ( array_slice( $items, 0, 5 ) as $item ) {
$names[] = esc_html( $item->product_name );
}
if ( count( $items ) > 5 ) {
$names[] = esc_html( 'and more' );
}
return implode( '<br>', $names );
}, 10, 3 );
Notes
Shows up to five items per order, then "and N more".
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.