/** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output **/ function widget($args, $instance) { global $wpdb; extract($args, EXTR_SKIP); $title = apply_filters('widget_title', $instance['title']); $limit = absint($instance['count']) ? absint($instance['count']) : 10; $cache_key = 'dokan-best-seller-' . $limit; $seller = wp_cache_get($cache_key, 'widget'); if (false === $seller) { $qry = "SELECT seller_id, display_name,SUM( net_amount ) AS total_sell\r\n FROM {$wpdb->prefix}dokan_orders AS o,{$wpdb->prefix}users AS u\r\n WHERE o.seller_id = u.ID\r\n GROUP BY o.seller_id\r\n ORDER BY total_sell DESC LIMIT " . $limit; $seller = $wpdb->get_results($qry); wp_cache_set($cache_key, $seller, 'widget'); } echo $before_widget; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul> <?php if ($seller) { foreach ($seller as $key => $value) { $rating = dokan_get_seller_rating($value->seller_id); $display_rating = $rating['rating']; if (!$rating['count']) { $display_rating = 'No ratings found yet!'; } ?> <li> <a href="<?php echo dokan_get_store_url($value->seller_id); ?> "> <?php echo $value->display_name; ?> </a><br /> <i class='fa fa-star'></i> <?php echo $display_rating; ?> </li> <?php } } ?> </ul> <?php echo $after_widget; }
/** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output **/ function widget($args, $instance) { extract($args, EXTR_SKIP); $title = apply_filters('widget_title', $instance['title']); $limit = absint($instance['count']) ? absint($instance['count']) : 10; $sellers = dokan_get_feature_sellers($limit); echo $before_widget; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="dokan-feature-sellers"> <?php if ($sellers) { foreach ($sellers as $key => $seller) { $store_info = dokan_get_store_info($seller->ID); $rating = dokan_get_seller_rating($seller->ID); $display_rating = $rating['rating']; if (!$rating['count']) { $display_rating = __('No ratings found yet!', 'dokan'); } ?> <li> <a href="<?php echo dokan_get_store_url($seller->ID); ?> "> <?php echo esc_html($store_info['store_name']); ?> </a><br /> <i class='fa fa-star'></i> <?php echo $display_rating; ?> </li> <?php } } ?> </ul> <?php echo $after_widget; }
/** * Dokan Featured Seller Widget Content Template * * @since 2.4 * * @package dokan */ ?> <ul class="dokan-feature-sellers"> <?php if ($sellers) { foreach ($sellers as $key => $seller) { $store_info = dokan_get_store_info($seller->ID); $rating = dokan_get_seller_rating($seller->ID); $display_rating = $rating['rating']; if (!$rating['count']) { $display_rating = __('No ratings found yet!', 'dokan'); } ?> <li> <a href="<?php echo dokan_get_store_url($seller->ID); ?> "> <?php echo esc_html($store_info['store_name']); ?> </a><br /> <i class='fa fa-star'></i>
/** * Get seller rating in a readable rating format * * @param int $seller_id * @return void */ function dokan_get_readable_seller_rating($seller_id) { $rating = dokan_get_seller_rating($seller_id); if (!$rating['count']) { echo __('No ratings found yet!', 'dokan'); return; } $long_text = _n(__('%s rating from %d review', 'dokan'), __('%s rating from %d reviews', 'dokan'), $rating['count'], 'dokan'); $text = sprintf(__('Rated %s out of %d', 'dokan'), $rating['rating'], number_format(5)); $width = $rating['rating'] / 5 * 100; ?> <span class="seller-rating"> <span title="<?php echo esc_attr($text); ?> " class="star-rating" itemtype="http://schema.org/Rating" itemscope="" itemprop="reviewRating"> <span class="width" style="width: <?php echo $width; ?> %"></span> <span style=""><strong itemprop="ratingValue"><?php echo $rating['rating']; ?> </strong></span> </span> </span> <span class="text"><a><?php printf($long_text, $rating['rating'], $rating['count']); ?> </a></span> <?php }
/** * Dokan Best Seller Widget Content Template * * @since 2.4 * * @package dokan */ ?> <ul class="dokan-best-sellers"> <?php if ($seller) { foreach ($seller as $key => $value) { $store_info = dokan_get_store_info($value->seller_id); $rating = dokan_get_seller_rating($value->seller_id); $display_rating = $rating['rating']; if (!$rating['count']) { $display_rating = __('No ratings found yet!', 'dokan'); } ?> <li> <a href="<?php echo dokan_get_store_url($value->seller_id); ?> "> <?php echo esc_html($store_info['store_name']); ?> </a><br /> <i class='fa fa-star'></i>