/** * Displays the store lists * * @since 2.4 * * @param array $atts * * @return string */ function store_listing($atts) { global $post; /** * Filter return the number of store listing number per page. * * @since 2.2 * * @param array */ $attr = shortcode_atts(apply_filters('dokan_store_listing_per_page', array('per_page' => 10)), $atts); $paged = max(1, get_query_var('paged')); $limit = $attr['per_page']; $offset = ($paged - 1) * $limit; $sellers = dokan_get_sellers($limit, $offset); ob_start(); if ($sellers['users']) { ?> <ul class="dokan-seller-wrap"> <?php foreach ($sellers['users'] as $seller) { $store_info = dokan_get_store_info($seller->ID); $banner_id = isset($store_info['banner']) ? $store_info['banner'] : 0; $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan'); $store_url = dokan_get_store_url($seller->ID); ?> <li class="dokan-single-seller"> <div class="dokan-store-thumbnail"> <a href="<?php echo $store_url; ?> "> <?php if ($banner_id) { $banner_url = wp_get_attachment_image_src($banner_id, 'medium'); ?> <img class="dokan-store-img" src="<?php echo esc_url($banner_url[0]); ?> " alt="<?php echo esc_attr($store_name); ?> "> <?php } else { ?> <img class="dokan-store-img" src="<?php echo dokan_get_no_seller_image(); ?> " alt="<?php _e('No Image', 'dokan'); ?> "> <?php } ?> </a> <div class="dokan-store-caption"> <h3><a href="<?php echo $store_url; ?> "><?php echo $store_name; ?> </a></h3> <address> <?php if (isset($store_info['address']) && !empty($store_info['address'])) { echo dokan_get_seller_address($seller->ID); } ?> <?php if (isset($store_info['phone']) && !empty($store_info['phone'])) { ?> <br> <abbr title="<?php _e('Phone Number', 'dokan'); ?> "><?php _e('P:', 'dokan'); ?> </abbr> <?php echo esc_html($store_info['phone']); ?> <?php } ?> </address> <p><a class="dokan-btn dokan-btn-theme" href="<?php echo $store_url; ?> "><?php _e('Visit Store', 'dokan'); ?> </a></p> </div> <!-- .caption --> </div> <!-- .thumbnail --> </li> <!-- .single-seller --> <?php } ?> </ul> <!-- .dokan-seller-wrap --> <?php $user_count = $sellers['count']; $num_of_pages = ceil($user_count / $limit); if ($num_of_pages > 1) { echo '<div class="pagination-container clearfix">'; $page_links = paginate_links(array('current' => $paged, 'total' => $num_of_pages, 'base' => str_replace($post->ID, '%#%', esc_url(get_pagenum_link($post->ID))), 'type' => 'array', 'prev_text' => __('← Previous', 'dokan'), 'next_text' => __('Next →', 'dokan'))); if ($page_links) { $pagination_links = '<div class="pagination-wrap">'; $pagination_links .= '<ul class="pagination"><li>'; $pagination_links .= join("</li>\n\t<li>", $page_links); $pagination_links .= "</li>\n</ul>\n"; $pagination_links .= '</div>'; echo $pagination_links; } echo '</div>'; } ?> <?php } else { ?> <p class="dokan-error"><?php _e('No seller found!', 'dokan'); ?> </p> <?php } $content = ob_get_clean(); return apply_filters('dokan_seller_listing', $content, $attr); }
<div id="content" class="site-content" role="main"> <?php while (have_posts()) { the_post(); ?> <?php get_template_part('content', 'page'); ?> <?php $paged = max(1, get_query_var('paged')); $limit = 12; $offset = ($paged - 1) * $limit; $sellers = dokan_get_sellers($limit, $offset); if ($sellers['users']) { ?> <div class="row"> <?php foreach ($sellers['users'] as $seller) { $store_info = dokan_get_store_info($seller->ID); $banner_id = isset($store_info['banner']) ? $store_info['banner'] : 0; $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan'); $store_url = dokan_get_store_url($seller->ID); ?> <div class="col-sm-6 col-md-4 single-seller"> <div class="thumbnail">
<?php // Exit if accessed directly if (!defined('ABSPATH')) { exit; } get_header(); ?> <?php $sellers = dokan_get_sellers(8); ?> <div class="featured-farm-section"> <div class="container"> <h2><span><?php _e('Featured farms', 'farmtoyou'); ?> </span></h2> <?php foreach ($sellers['users'] as $seller) { $args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'author' => $seller->ID, 'fields' => 'ids'); $product_ids = get_posts($args); $seller_products = !empty($product_ids) ? count($product_ids) : 0; $store_info = dokan_get_store_info($seller->ID); $banner_id = isset($store_info['banner']) ? $store_info['banner'] : 0; $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan'); $store_url = dokan_get_store_url($seller->ID); $seller_icon = get_user_meta($seller->ID, 'dokan_seller_icon', true); ?> <div class="col-md-3 feature-box"> <div class="ff-box">
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); // before and after widget arguments are defined by themes echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } $sellers = dokan_get_sellers(1); foreach ($sellers['users'] as $seller) { $args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'author' => $seller->ID, 'fields' => 'ids'); $product_ids = get_posts($args); $seller_products = !empty($product_ids) ? count($product_ids) : 0; $store_info = dokan_get_store_info($seller->ID); $banner_id = isset($store_info['banner']) ? $store_info['banner'] : 0; $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan'); $store_url = dokan_get_store_url($seller->ID); $seller_icon = get_user_meta($seller->ID, 'dokan_seller_icon', true); ?> <div class="ff-box"> <?php if ($banner_id) { $banner_url = wp_get_attachment_image_src($banner_id, 'full'); ?> <a href="<?php echo $store_url; ?> "> <img src="<?php echo $banner_url[0]; ?> " class="img-responsive2"> </a> <?php } ?> <div class="ff-detail"> <?php if (!empty($seller_icon)) { ?> <div class="ffd-image"> <a href="<?php echo $store_url; ?> "> <img src="<?php echo $seller_icon; ?> " class="img-responsive2"> </a> </div> <?php } ?> <div class="feature-title"> <?php if (!empty($store_name)) { ?> <h6><a href="<?php echo $store_url; ?> "><?php echo $store_name; ?> </a></h6> <?php } ?> <span><?php echo sprintf(_n('%s item', '%s items', $seller_products, 'farmtoyou'), $seller_products); ?> </span> </div> <div class="ffd-click"><a href="<?php echo $store_url; ?> "><i class="fa fa-angle-right"></i></a></div> </div> </div> <?php } ?> <?php echo $args['after_widget']; }