Skip to content

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.

Note: If you need to show store name instead of vendor name then you can replace the line number 18 with this line-

<?php printf( 'Sold by: <a href="%s">%s</a>', $vendor->get_shop_url(), $vendor->get_shop_name() ); ?>

 

Published inDokanMultivendorWooCommerceWordPress

14 Comments

  1. Hi,
    thanks for this but it didn’t work for me

    Any help sir

    • Hello,

      It depends on how you inserted the code. For me, it is still working. Kindly make sure if you are not doing any mistake.

      • sharif sharif

        It’s not working for me too.

      • sharif sharif

        I am using the electro child theme

  2. sharif sharif

    I am using the electro child theme. I have inserted this code in the functions.php file in the child theme. But not working.

    • 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.

  3. 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.

    • The code is working fine on my local server. Kindly check correctly if you have inserted everything correctly or not 🙂

  4. 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

    • 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!

  5. 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 } }

  6. hajer hajer

    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.

  7. hajer hajer

    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.

    • Did you install Dokan plugin? If yes, then make sure that you have inserted the code correctly or your theme does not have the same function called.

Leave a Reply

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

%d bloggers like this: