mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://stackoverflow.com/questions/65375496/add-permalink-to-product-title-in-woocommerce-custom-order-history/65376018
23 lines
914 B
Text
23 lines
914 B
Text
add_filter( 'woocommerce_my_account_my_orders_columns', 'additional_my_account_orders_column', 10, 1 );
|
|
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'] = __( 'Items', 'woocommerce' );
|
|
}
|
|
}
|
|
return $new_columns;
|
|
}
|
|
|
|
add_action( 'woocommerce_my_account_my_orders_column_order-items', 'additional_my_account_orders_column_content', 10, 1 );
|
|
function additional_my_account_orders_column_content( $order ) {
|
|
$details = array();
|
|
|
|
foreach( $order->get_items() as $item )
|
|
$details[] = '<a href="' . $item->get_product()->get_permalink() . '">' . $item->get_name() . '</a> × ' . $item->get_quantity();
|
|
|
|
echo count( $details ) > 0 ? implode( '<br>', $details ) : '–';
|
|
}
|