Closed. This question needs details or clarity. It is not currently accepting answers.admin管理员组文章数量:1122846
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this questionI am going to add the Dokan seller badge list to the single product page by creating a shortcode so that the tooltip is also displayed. Thank you for your guidance.
Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this questionI am going to add the Dokan seller badge list to the single product page by creating a shortcode so that the tooltip is also displayed. Thank you for your guidance.
Share Improve this question asked May 12, 2024 at 6:12 negar filenegar file 1 2- Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Bot Commented May 13, 2024 at 17:35
- You have to ask DOKAN's support/dev team how to do this. – Tony Djukic Commented May 13, 2024 at 17:58
1 Answer
Reset to default 1// Add shortcode to display Dokan Seller Badge on Single Product Page
function display_dokan_seller_badge() {
if ( function_exists( 'dokan_get_vendor_by_product' ) ) {
global $post;
$product_id = $post->ID; // Get the current product ID
$vendor = dokan_get_vendor_by_product( $product_id ); // Get the vendor information from the product ID
if ( $vendor ) {
$vendor_id = $vendor->get_id(); // Get the vendor ID
// Fetch the seller badge meta associated with the vendor ID
$badge_id = get_user_meta( $vendor_id, 'dokan_seller_badge_id', true );
if ( !empty( $badge_id ) ) {
$badge_image = wp_get_attachment_image( $badge_id, 'full' ); // Get the seller badge image
if ( !empty( $badge_image ) ) {
return '<div class="dokan-seller-badge">' . $badge_image . '</div>'; // Return the badge image wrapped in a div
}
} else {
return '<p>No Seller Badge Available</p>'; // If no badge is found
}
}
}
return ''; // Return empty if no vendor or badge is found
}
// Register the shortcode [dokan_seller_badge]
add_shortcode( 'dokan_seller_badge', 'display_dokan_seller_badge' );
本文标签: phpHow do I make a shortcode to display Dokan seller badge list
版权声明:本文标题:php - How do I make a shortcode to display Dokan seller badge list? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736285111a1927390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论