Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Last active January 29, 2024 08:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/1fc0c4840fc6da5ce08c8ac5d0bcd721 to your computer and use it in GitHub Desktop.
Save nayemDevs/1fc0c4840fc6da5ce08c8ac5d0bcd721 to your computer and use it in GitHub Desktop.
Creating a shortcode to show vendor biography anywhere on your page
<?php
/**
* Plugin Name: Dokan Vendor Biography Shortcode
*/
add_shortcode( 'dokan_vendor_bio', 'dokan_vendor_bio_shortcode' );
function dokan_vendor_bio_shortcode() {
$vendor = dokan()->vendor->get( get_query_var( 'author' ) );
$store_info = $vendor->get_shop_info();
if ( empty( $store_info['vendor_biography'] ) ) {
return;
}
printf( '%s', apply_filters( 'the_content', $store_info['vendor_biography'] ) );
}
// user vendor bio shortcode on single product page
add_shortcode( 'dokan_vendor_bio_single', 'dokan_vendor_bio_shortcode_single' );
function dokan_vendor_bio_shortcode_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['vendor_biography'] ) ) { ?>
<span class="details">
<?php printf( $vendor->get_vendor_biography() ); ?>
</span>
<?php
}
}
@nayemDevs
Copy link
Author

Guys, I created a new youtube channel- https://www.youtube.com/channel/UCi_pjYuycQCC705hdSv52qA . You can subscribe and suggest me if you need any tutorial :)

Cheers!

@Deexterous
Copy link

This code is not working after the latest update. Any suggestions? kulavillage.com is my site

@daihlo
Copy link

daihlo commented May 25, 2021

This still doesnt work for me.

Used the code at the top of this page using snippet plugin, activated it, then in elementor placed a shortcode block on my vendor store page above products - with shortcode [dokan_vendor_bio]
Nothing happens.

@Gurtop
Copy link

Gurtop commented Nov 9, 2021

Hi!
Seller biography on dokan product page made with elemental, no works (
Help?

@DavisMorten
Copy link

Works perfectly fine for me. THX mate! :)

@fdead0
Copy link

fdead0 commented Feb 4, 2023

I want to add vendor signature field somewhere in setting>store section in vendor dashboard and how to use it's short code to print it on invoice???

@asansano
Copy link

asansano commented Jan 29, 2024

think the $store_info array changed a bit. we changed line 8 to $store_info = dokan_get_store_info($vendor->id); you might want to update your code.

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