Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Last active April 26, 2022 16:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/6d0f1ff033c6ba6f90e777110be17bbd to your computer and use it in GitHub Desktop.
Save nayemDevs/6d0f1ff033c6ba6f90e777110be17bbd to your computer and use it in GitHub Desktop.
Show Store name on product thumbnail instead of vendor name
<?php
/*
Show Store name on the product thumbnail For Dokan Multivendor plugin
*/
add_action( 'woocommerce_after_shop_loop_item_title','sold_by' );
function sold_by(){
?>
</a>
<?php
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 );
if ( !empty( $store_info['store_name'] ) ) { ?>
<span class="details">
<?php printf( 'Sold by: <a href="%s">%s</a>', $vendor->get_shop_url(), $vendor->get_shop_name() ); ?>
</span>
<?php
}
}
?>
@dkuhn22
Copy link

dkuhn22 commented Mar 28, 2022

Thank you for the code! It works great. How can i center the Text? And is it possible to add more information there with custom fields i added in the vendors profile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment