Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Last active September 14, 2019 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/b64e387ea82c3835aee681a34bad7a2b to your computer and use it in GitHub Desktop.
Save nayemDevs/b64e387ea82c3835aee681a34bad7a2b to your computer and use it in GitHub Desktop.
Show store name on single product page
/*Show store name on single product*/
add_action( 'woocommerce_single_product_summary', 'seller_name_on_single', 12 );
function seller_name_on_single(){
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment