Home Forums WC Vendors Free Support How to echo the VendorsID on the order details page (backend)?

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 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #14015
    wzshop
    Participant

    Hi,
    I’m trying to make a custom reference to an order. For this, I was wondering how i can display the vendorsID for each of the Vendors that supply, for that certain order.

    So, someone might have 1 order, ordering from vendorID 1 and vendorID 2. I would like to echo the vendorID for both vendors on the order details page in the backend. I already have a hook and some code like this (watch for $VENDORID HERE):

    function kia_display_order_data_in_admin( $order ){  ?>
        <div class="order_data_column">
            <h4><?php _e( 'Reference(s)', 'woocommerce' ); ?></h4>
            <?php 
        global $post;    
    	$customer_user = get_post_meta( $post->ID, '_customer_user', true );
    $customer_orders = get_posts( array(
        'numberposts' => -1,
        'meta_key'    => '_customer_user',
        'meta_value'  => $customer_user,
        'post_type'   => wc_get_order_types(),
        'post_status' => array_keys( wc_get_order_statuses() ),
    ) );
    	
    $order = new WC_Order( $post->ID );
    $items = $order->get_items();
    
    	foreach ( $items as $item ) {
        $product_name = $item['name'];
        $product_id = $item['product_id'];
        $product_variation_id = $item['variation_id'];
    echo $product_id.'.'.$customer_user.'.'.count( $customer_orders ).$VENDORID HERE.'.#'.$post->ID.'<br>'; 
    }
    

    Thanks!

    #14078
    WC Vendors Support
    Participant

    This one’s all you. 🙂 Customization services start at $49/hr. 🙂 You’d want to run through each product purchased in the order ID, and then look at the post_author for the vendors ID.

    #14134
    wzshop
    Participant

    Hi Ben,
    Thanks a lot.

    When i do print_r ($item); i do not see an key that contains the author ID correct?
    I only find the vendors name, and could probably match that with user_meta to get the authors/vendors id..

    Would that be the correct way of doing it?

    #14135
    wzshop
    Participant

    Nevermind, found a code to do it. Will post it here once completed. Thanks

    #14136
    Jamie
    Keymaster

    Hi Wzshop,

    Is this for the admins to see the vendors, cause we already display that near the top of the order. Or do you specifically need the ID and not the vendors name?

    cheers,

    Jamie.

    #14142
    wzshop
    Participant

    Hey,
    Still struggling;) Well i am trying to get the authors/vendors ID of all the items that are sold within an order.
    Any advice is still welcome:)

    #14147
    wzshop
    Participant

    This piece of code within the foreach did the trick $vendor = WCV_Vendors::get_vendor_from_product( $product_id );

    Thanks

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