How To Show Vendor Name On The Product Thumbnail In Dokan Multivendor Plugin by weDevs

Every marketplace owner always looks for making their website more user-friendly. They want to save their customer’s time.

I am getting the below question from many users to add vendor name with Store URL on the product thumbnail:

Hi!

I want to display the vendor’s name alongside the Product name and price on the shop page (the thumbnails of products). Can you help?

How to add vendor name on the product thumbnail?

If you are using Dokan plugin and if You can easily add the vendor name with the Store URL on the product thumbnail by adding some custom codes in your child theme. On the thumbnail, it can be shown like below-

Now, if you click on the vendor name then it will redirect you to the vendor store page. If you are looking for the same thing then add the below code in your child theme’s functions.php file –

I believe the above code snippet will help you and if you need to modify anything then you can change it as per your requirement.

Important Note

If you need to show store name instead of vendor name then you have to use below codes and do not copy the first line and the last line with <?php and ?>

21 thoughts on “How To Show Vendor Name On The Product Thumbnail In Dokan Multivendor Plugin by weDevs

    1. Hello,

      It can be for your theme. Each theme does not use the same function for the product thumbnail. Kindly check with a default theme and let me know the update.

  1. im receiving this error:

    Uncaught Error: Call to a member function get_id() on null in wp-content/themes/alpha-store-pro-updated-child/functions.php:245
    Stack trace:

    thanks in advance for any help you might provide.

  2. when i copy and paste that code directly into my functions.php without making and changes i receive this error:

    Your PHP code changes were rolled back due to an error on line 259 of file wp-content/themes/alpha-store-pro-updated-child/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘}’, expecting end of file

    i tried replacing the last ‘}’ with ?> and then i received this error:

    Your PHP code changes were rolled back due to an error on line 248 of file wp-content/themes/alpha-store-pro-updated-child/functions.php. Please fix and try saving again.

    Uncaught Error: Call to a member function get_id() on null in wp-content/themes/alpha-store-pro-updated-child/functions.php:248
    Stack trace:
    #0 wp-settings.php(424): include()
    #1 wp-config.php(79): require_once(‘/home/stufffor/…’)
    #2 wp-load.php(37): require_once(‘/home/stufffor/…’)
    #3 wp-admin/admin.php(31): require_once(‘/home/stufffor/…’)
    #4 wp-admin/theme-editor.php(10): require_once(‘/home/stufffor/…’)
    #5 {main}
    thrown

    1. also please note that i used the other code you provided for adding the vendor name to the single product page and that one worked perfectly! thanks again for all your help i really appreciate it. these are really cool features to add to the shop. just hope i can get this thumbnails one working as well. thanks!

  3. Please note that you are missing “}” which was closing for the function. Kindly check the code in RAW mode. I just checked the code again and its working fine.


    add_action( 'woocommerce_after_shop_loop_item_title','sold_by' );

    function sold_by(){
    ?>

    < ?php global $product; $seller = get_post_field( 'post_author', $product->get_id());
    $author = get_user_by( 'id', $seller );

    $store_info = dokan_get_store_info( $author->ID );
    if ( !empty( $store_info['store_name'] ) ) { ?>

    < ?php printf( 'Sold by: %s', dokan_get_store_url( $author->ID ), $author->display_name ); ?>

    < ?php } }

  4. Hello. I get this error
    Uncaught Error: Call to undefined function dokan_get_store_info() in wp-content/themes/xstore-child/functions.php:244

    How can solve this.

  5. Hello. I get this error
    Uncaught Error: Call to undefined function dokan_get_store_info() in wp-content/themes/xstore-child/functions.php:244

    How can solve this.

  6. Hi,

    Whenever I change line 18 to this code: <?php printf( 'Sold by: %s‘, $vendor->get_shop_url(), $vendor->get_shop_name() ); ?>, the website keep loading non stop. When I change it back to original, everything fine. Any possible way to show vendors name instead of seller name?

    1. It should work fine. However, this blog was written a year ago and if the code is not working then you may need to modify 🙂 Which theme are you using?

      1. So the code that works for store is this right?, I’m not programmer at all, I just want to be sure, I have to copy and past the code from that php start until the end as it is and is going to work? because the last time it broke my site

        get_id());
        $author = get_user_by( ‘id’, $seller );
        $vendor = dokan()->vendor->get( $seller );
        $store_info = dokan_get_store_info( $author->ID );
        if ( !empty( $store_info[‘store_name’] ) ) { ?>

        <?php printf( 'Sold by: %s‘, $vendor->get_shop_url(), $vendor->get_shop_name() ); ?>

Leave a Reply

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