Table column values not displaying correctly

I have table column “Profile” that needs to output a hyperlink, specifically profile link of a customer that bought a product.

Updated

There are two issues:

1) In the Profile column (which should present hyperlink of a customer who bought a product) there is just always number “1” no matter which customer purchases a product…so there’s no profile hyperlink in that column to link to customer’s profile.

2) Hyperlink “Click here to view user profile” which is linking to customer profile is outside the table (specifically above the table).

It’s a “user_link” in question, here’s how it is now:

$new_row->ID            = $order->get_order_number(); 
                $new_row->order_number  = $order->get_order_number(); 
                $new_row->customer      = $customer_details; 
                $new_row->products      = $products_html;
                $new_row->total         = $total_text;
                $new_row->status        = $shipped;
                $new_row->user_link     = get_post_meta( $order->id, '_user_link', true );
                $new_row->order_date    = date_i18n( wc_date_format(), strtotime( $order->order_date ) ) . '<br /><strong>' . ucfirst( $order->get_status() ) . '</strong>'; 
                $new_row->row_actions   = $row_actions; 
                $new_row->action_after  = $this->order_details_template( $_order ) . $this->order_note_template( $order->get_order_number() ) . $this->tracking_number_template( $order->get_order_number(), get_current_user_id() ); 

                do_action( 'wcv_orders_add_new_row', $new_row ); 

                $rows[] = $new_row; 

Table columns:

public function table_columns( ) {

        $columns = apply_filters( 'wcv_order_table_columns', array( 
                    'ID'            => __( 'ID',            'wcvendors-pro' ), 
                    'order_number'  => __( 'Purchase ID',       'wcvendors-pro' ),
                    'customer'      => __( 'Customer',      'wcvendors-pro' ),
                    'products'      => __( 'Product)',      'wcvendors-pro' ), 
                    'total'         => __( 'Total',         'wcvendors-pro' ), 
                    'order_date'    => __( 'Sale Date',     'wcvendors-pro' ),
                    'user_link'     => __( 'Profile', 'wcvendors-pro'),
        ) ); 

What I tried: In the $new_row->user_link I tried adding print:

$new_row->user_link  = print '<p><a class="author-link" href="'. $order->user_link .'">'. __( 'Click here to view user profile' ) . '</a><p>';

Read more here: Table column values not displaying correctly

Leave a Reply

Your email address will not be published. Required fields are marked *