Last active
July 28, 2022 11:27
-
-
Save nayemDevs/cf150250a995d680a2dace9daa712e64 to your computer and use it in GitHub Desktop.
Show store name on single product page (Sold by: vendor) when you have created single product via Elementor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show sold by on single product page made with Elementor | |
* Add the shortcode [dokan_vendor_name] through a short-code widget on single product page | |
*/ | |
add_shortcode( 'dokan_vendor_name', 'dokan_store_name_shortcode' ); | |
function dokan_store_name_shortcode() { | |
$seller = get_post_field( 'post_author' ); | |
$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
How to show vendor name in vendor dashboard?