feat(admin): native paid-post sales report page
Add aksrt_pay_products under payment center for content-pay posts (resource orders), with order aggregation and deep-link filters.
This commit is contained in:
@@ -48,10 +48,12 @@ class AKSRT_Admin_Pay_Orders {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
|
||||
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
|
||||
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
|
||||
$per_page = 20;
|
||||
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
|
||||
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
|
||||
$product_type = isset($_GET['product_type']) ? sanitize_key((string) wp_unslash($_GET['product_type'])) : '';
|
||||
$product_id = isset($_GET['product_id']) ? max(0, (int) $_GET['product_id']) : 0;
|
||||
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
|
||||
$per_page = 20;
|
||||
|
||||
$repo = AKSRT_Order_Repository::get_instance();
|
||||
$args = [
|
||||
@@ -61,6 +63,12 @@ class AKSRT_Admin_Pay_Orders {
|
||||
if ($status !== '' && $status !== 'all') {
|
||||
$args['status'] = $status;
|
||||
}
|
||||
if ($product_type !== '') {
|
||||
$args['product_type'] = $product_type;
|
||||
}
|
||||
if ($product_id > 0) {
|
||||
$args['product_id'] = $product_id;
|
||||
}
|
||||
|
||||
$items = $repo->get_orders_admin($args, $search);
|
||||
$total = $repo->get_orders_count($args, $search);
|
||||
@@ -71,6 +79,12 @@ class AKSRT_Admin_Pay_Orders {
|
||||
|
||||
echo '<form method="get" style="margin:12px 0;">';
|
||||
echo '<input type="hidden" name="page" value="aksrt_orders" />';
|
||||
if ($product_type !== '') {
|
||||
echo '<input type="hidden" name="product_type" value="' . esc_attr($product_type) . '" />';
|
||||
}
|
||||
if ($product_id > 0) {
|
||||
echo '<input type="hidden" name="product_id" value="' . esc_attr((string) $product_id) . '" />';
|
||||
}
|
||||
echo '<select name="status">';
|
||||
echo '<option value="">' . esc_html__('全部状态', 'aksrt') . '</option>';
|
||||
foreach ($labels as $key => $label) {
|
||||
@@ -84,6 +98,17 @@ class AKSRT_Admin_Pay_Orders {
|
||||
echo '</select> ';
|
||||
echo '<input type="search" name="s" value="' . esc_attr($search) . '" placeholder="' . esc_attr__('订单号 / 类型', 'aksrt') . '" /> ';
|
||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||
if ($product_id > 0 || $product_type !== '') {
|
||||
$filter_bits = [];
|
||||
if ($product_type !== '') {
|
||||
$filter_bits[] = sprintf(__('类型=%s', 'aksrt'), $product_type);
|
||||
}
|
||||
if ($product_id > 0) {
|
||||
$filter_bits[] = sprintf(__('商品ID=%d', 'aksrt'), $product_id);
|
||||
}
|
||||
echo ' <span class="description">' . esc_html(implode(' · ', $filter_bits)) . '</span>';
|
||||
echo ' <a class="button button-small" href="' . esc_url($this->page_url('aksrt_orders')) . '">' . esc_html__('清除商品过滤', 'aksrt') . '</a>';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
echo '<table class="wp-list-table widefat fixed striped">';
|
||||
|
||||
Reference in New Issue
Block a user