Display product vendor name on single product page!

Are you a Dokan Multivendor plugin user? If yes, then this tips can help you a lot. In another post of mine, I have described that how you can show vendor store name on product thumbnail. After publishing the post I got many requests to write another post at a similar point but this time vendor name needs to show on the single product page.

To promote the vendor or to inform the customer about the vendor, the site admin always try to show the original owner of the product. On the single product page, there is a tab called “Vendor Information” to show vendor address, email etc. Nowadays, no one has the time to check each tab because everyone wants to save their time.

You are also thinking to add an option to the single product page description where the customer can view the original vendor who is selling the product. You are thinking to add an option to show¬† “Sold by:¬†[store name]” on the single product page under the product summary.

How to show sold by tag on the single product page?

I found a quick solution to show vendor store name on the single product page. It is really quick and easy solution. Just open your child-theme functions.php file and add the below code :

<?php

add_action( 'woocommerce_single_product_summary', 'seller_name_on_single', 11 );
     function seller_name_on_single(){
               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'] ) ) { ?>
                <span class="details">
                    <?php printf( 'Sold by: <a href="%s">%s</a>', dokan_get_store_url( $author->ID ), $store_info['store_name'] ); ?>
                </span>
        <?php 
        } else {
            ?>  
            <span class="details">
                    <?php printf( 'Sold by: <a href="%s">%s</a>', dokan_get_store_url( $author->ID ), $author->display_name ); ?>
                </span>
            <?php
        }
     } 
?>

After saving the file, just reload the single product page and you will be able to see the vendor store name on the single product page under the product summary.

I beleive that this small tips can help you a lot. If you are not using Dokan plugin then you can take a look here.

Leave a Reply

%d bloggers like this: