The WordPress/Dokan multi-vendor store plugin shows the vendor contact information on a tab “below the fold” on many devices. I wanted to add the vendor name and contact information in a more visible location, below the product short description and price.
I worked from this stackoverflow code and modified it so it shows the Vendor Name, Email, Phone. This code would go in the child theme functions.php file.
Code:
// Display vendor contact information
add_action( 'woocommerce_single_product_summary', 'show_vendor_name', 20 );
function show_vendor_name() {
global $product;
$seller = get_post_field( 'post_author', $product->get_id());
$author = get_user_by( 'id', $seller );
$vendor = dokan()->vendor->get( $seller );
$store_info = dokan_get_store_info( $author->ID );
// Output display
printf( '<div class="prod-exhib prod-field"><h3>Vendor Contact Information</h3><p><a href="%s">%s</a></p></div>', $vendor->get_shop_url(), $vendor->get_shop_name() );
if ( ! dokan_is_vendor_info_hidden( 'email' ) && $vendor->show_email() == 'yes' ) {
?>
<div class="prod-email prod-field"><i class="fa fa-envelope-o"> </i> <a href="mailto:<?php echo esc_attr( antispambot( $vendor->get_email() ) ); ?>"><?php echo esc_attr( antispambot( $vendor->get_email() ) ); ?></a></div>
<?php }
if ( ! dokan_is_vendor_info_hidden( 'phone' ) && ! empty( $vendor->get_phone() ) ) {
printf( '<div class="prod-phone prod-field"><i class="fa fa-mobile"></i> <a href="tel:%s">%s</a></i></div>', $vendor->get_phone(), $vendor->get_phone() );
}
}