Home Forums WC Vendors Free Support Vendors details in order_details_customer.php

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

    How I can get and display data of the seller of the order. These data are necessary for the buyer.
    In the file ‘order_details customer.php’ and made a place to put these data.

    If the purchase was made more than a vendor, I can get all the data?

    Thanks.

    #11700
    WC Vendors Support
    Participant

    Hi CriterioNet,

    Basically, query the order ID for all the data and then do with that what you wish! 🙂

    https://docs.woothemes.com/wc-apidocs/class-WC_Order.html

    http://wordpress.stackexchange.com/questions/97176/get-product-id-from-order-id-in-woocommerce

    Cheers,

    Ben

    #11724
    CriterioNet
    Participant

    I need the id of the author of the product (the seller). I think WC_Order not provide that information.

    I can display data vendor, but applying the user ID manually.

    This is my code:

    $vendor_id = 29; // <- how get the id ?
    	$vendor_data = get_userdata( $vendor_id );
    	$vendor_email = $vendor_data->user_email;
      	$vendor_name = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
    	$vendor_phone =  get_user_meta($vendor_id, 'billing_phone', true);
    	$vendor_details = $vendor_name . '<br> Email: ' . $vendor_email . '<br> Teléfono: ' .$vendor_phone;
    	echo $vendor_details;
    
    
    		
    	
    #11738
    WC Vendors Support
    Participant

    If you know the product ID, get the post_author for the product ID, and that is your $vendor_id

    Something like $vendor_id = get_post_meta( $product_id, ‘post_author’, true );

    #11880
    CriterioNet
    Participant

    If another need this, so I did:

    copy template (yourtheme/woocommerce/order/order_details.php)

    in order_details.php changue las line:
    wc_get_template( 'order/order-details-customer.php', array( 'order' => $order, 'item' => $item ) );

    in order-details-customer.php add:


    <!-- datos del vendedor -->
    <div class="col-2">

    <header>
    <h2><?php _e( 'Vendor Details', 'woocommerce' ); ?></h2>
    </header>

    <?php foreach( $order->get_items() as $item_id => $item ) { ?>

    <?php
    $product_name = $item['name'];
    $product_id = $item['product_id'];
    $vendor_id = get_post_field( 'post_author', $product_id );
    $vendor_data = get_userdata( $vendor_id );
    $vendor_email = $vendor_data->user_email;
    $vendor_name = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
    $vendor_phone = get_user_meta($vendor_id, 'billing_phone', true);
    $vendor_details = ' Producto: ' . $product_name . ' <br> Artesano: '.$vendor_name . '<br> Email: ' . $vendor_email . '<br> Teléfono: ' .$vendor_phone;
    echo $vendor_details;
    ?>
    <hr>
    <?php } ?>

    </div>
    <!-- /datos del vendedor -->

    If there are several products on the order are displayed correctly identifying the vendor by the name of the product.

    Thanks Ben for your help!

    #11917
    WC Vendors Support
    Participant

    Very nice! You’re hired. 🙂

    #31096
    CriterioNet
    Participant

    Hello @ben, I think the billing_phone variable has been lost

    $vendor_phone = get_user_meta($vendor_id, 'billing_phone', true);

    Now I would like to change and get the phone they enter in the store settings. What is the value you have to add?

    #31098
    WC Vendors Support
    Participant

    _wcv_store_phone is the meta key for the vendors profile store phone. billing_phone is a WooCommerce order meta key.

    #58637
    Karol Salinas
    Participant

    Hello!! I tried to put the code directly into the email template (into the WordPress dashboard → Woocommerce → Emails) and it works!
    I have new field with the last CriterioNet code: Add BuddyPress Profile (and hide Phone).
    This:
    $profile_url = bp_core_get_user_domain ( $vendor_id );
    and this:
    '<br> Perfil: <a href="'. $profile_url .'">Contactar</a>'

    So, the final code looks:

    <!-- datos del vendedor -->
    get_items() as $item_id => $item ) { ?>
    
    user_email;
    $vendor_name = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
    $profile_url =          bp_core_get_user_domain ( $vendor_id );
    $vendor_phone = get_user_meta($vendor_id, '_wcv_store_phone', true);
    $vendor_details = ' Producto: ' . $product_name . '  Vendedor: '.$vendor_name . ' Email: ' . $vendor_email . ' Perfil: <a href="'. $profile_url .'">Contactar</a>';
    echo $vendor_details;
    ?>
    <!-- /datos del vendedor -->

    Good luck!
    Karol Salinas.

    #58657
    patrick mark
    Participant

    is there a way i can get meta data with a product and the vendor that sells it as an array from the cart page to use in function .php.

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