Skip to content

Instantly share code, notes, and snippets.

@therakeshm
Forked from nayemDevs/functions.php
Created November 23, 2018 18:06
Show Gist options
  • Save therakeshm/83e350e72b640a0795da1b9cc4629e5e to your computer and use it in GitHub Desktop.
Save therakeshm/83e350e72b640a0795da1b9cc4629e5e to your computer and use it in GitHub Desktop.
adding sold by option on the single product page
<?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 ), $author->display_name ); ?>
</span>
<?php
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment