Purchased.php
1.41 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace ACA\WC\Column\Order;
use AC;
use ACA\WC\Sorting\Order\ItemsSold;
use ACP\Sorting\Sortable;
class Purchased extends AC\Column implements AC\Column\AjaxValue, Sortable
{
public function __construct()
{
$this->set_type('column-order_purchased')
->set_label(__('Products Sold', 'codepress-admin-columns'))
->set_group('woocommerce');
}
public function get_value($id)
{
$order = wc_get_order($id);
$count = $order ? $order->get_item_count() : 0;
if ( ! $count) {
return $this->get_empty_char();
}
$count = sprintf(_n('%d item', '%d items', $count, 'codepress-admin-columns'), $count);
return ac_helper()->html->get_ajax_modal_link($count, [
'title' => get_the_title($id),
'edit_link' => get_edit_post_link($id),
'class' => "-nopadding",
]);
}
public function get_ajax_value($id)
{
$order = wc_get_order($id);
if ( ! $order) {
return false;
}
$order_items = $order->get_items();
if (count($order_items) <= 0) {
return false;
}
$view = new AC\View([
'items' => $order_items,
]);
echo $view->set_template('modal-value/purchased')->render();
exit;
}
public function sorting()
{
return new ItemsSold();
}
}