/
TopSellers.php
executable file
·52 lines (42 loc) · 1014 Bytes
/
TopSellers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Jigoshop\Admin\Reports\Chart\Widget;
use Jigoshop\Admin\Reports\Chart\WidgetInterface;
use Jigoshop\Helper\Render;
class TopSellers implements WidgetInterface
{
const SLUG = 'top_sellers';
private $topSelers;
public function __construct($topSellers)
{
$this->topSelers = $topSellers;
}
public function getSlug()
{
return self::SLUG;
}
public function getTitle()
{
return __('Top Sellers', 'jigoshop');
}
public function getArgs()
{
$args = array();
foreach($this->topSelers as $product){
$args[] = array(
'count' => $product->count,
'id' => $product->id,
'url' => esc_url(add_query_arg('product_ids', $product->id, add_query_arg('last_used', self::SLUG))),
'title' => $product->title
);
}
return $args;
}
public function isVisible()
{
return (isset($_GET['last_used']) && $_GET['last_used'] == self::SLUG);
}
public function display()
{
Render::output('admin/reports/widget/top_sellers', array('args' => $this->getArgs()));
}
}