Home Forums WC Vendors Pro Support Display additional information from checkout on orders dashboard

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #61645
    Marko
    Participant

    Hi,

    I’ve created custom hidden field on woocommerce checkout, that saves additional information from a customer. Specifically customer’s author profile link. So when a vendor A makes a purchase from vendor B, vendor A’s author URL is saved like this: https://example.com/author/vendorA , I’m doing this so that vendors can see personal profiles from those vendors who bought a product. It’s kind of a marketplace where vendors can purchase products from each other.

    So I want to display this URL value on vendor’s order page under customer details(under the name) who bought the product.

    Can anyone suggest me how to achieve this?

    Thanks!

    Here’s a code below that’s doing what I’ve described:

    add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_hidden_field', 10, 1 );
    function my_custom_checkout_hidden_field( $checkout ) {
    
        // Get an instance of the current user object
        $user = wp_get_current_user();
    
        // The user link
        $user_link = home_url( '/author/' . $user->user_login );
    
        // Output the hidden link
        echo '
                
        ';
    }
    
    add_action( 'woocommerce_checkout_update_order_meta', 'save_custom_checkout_hidden_field', 10, 1 );
    function save_custom_checkout_hidden_field( $order_id ) {
    
        if ( ! empty( $_POST['user_link'] ) )
            update_post_meta( $order_id, '_user_link', sanitize_text_field( $_POST['user_link'] ) );
    
    }
    #61778
    Marko
    Participant

    Anyone knows if there is a possible solution for this? Which file would I need to edit?

    #61845
    Anna
    Member

    This may help you– the last part of the Gist shows how I rendered info entered in a custom filed on the product page into the order details and emails.
    https://gist.github.com/fervous/ffac7ed154a4287414ea2da675cbdc17

    #61869
    Marko
    Participant

    Hi Anna, thanks for this. I’m not sure if this is what I’m looking for: Basically I need to display this custom checkout field from checkout on vendor’s dashboard (not on Woocommerce order pages), under customer details who bought the product(or somewhere else in that orders dashboard table in vendor’s dashboard).

    Is this last part of your gist can be used in relation to what I’ve described?

    Thanks.

    #61907
    Marko
    Participant

    Here’s what I did:

    I added $new_row in pro-order-controller “user_link”:

    $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     = $user_link;
    				$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; 
    
    			} 

    And in the same file, I added a “Profile” column in table columns:

    public function table_columns( ) {
    
    		$columns = apply_filters( 'wcv_order_table_columns', array( 
    					'ID' 			=> __( 'ID', 			'wcvendors-pro' ), 
    					'order_number'	=> __( 'Order Number', 		'wcvendors-pro' ),
    					'customer'  	=> __( 'Customer', 		'wcvendors-pro' ),
    					'products'  	=> __( 'Product', 		'wcvendors-pro' ), 
    					'total'  		=> __( 'Commission', 		'wcvendors-pro' ), 
    				       'order_date'  	=> __( 'Sale Date', 	'wcvendors-pro' ),
                                           'user_link'     => __( 'Profile', 'wcvendors-pro'),
    		) ); 

    So this is displaying a new column in table column, but the Profile column is empty there’s no link in it..

    #61909
    Marko
    Participant

    Here’s a solution but this is only displays URL without hyperlink if anyone needs it:

    Just change $new_row for “user_link” field with this:

    $new_row->user_link = get_post_meta( $order->id, '_user_link', true );

    Still figuring out how to make hyperlink for this new_row

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.