feat(shop): complete storefront archive, seller edit, revenue

Wire product cat/tag archives to settings-driven sort and AJAX paging,
seller product options/video/params editing, revenue withdraw form and
order review submit — finishing remaining shop frontend gaps after buy-path.
This commit is contained in:
kate522 committed 2026-07-12 10:38:02 +08:00
1 parent 5a8f08db8a
commit f3db6c89cc
17 files changed
+1024 -248

No files matched your search

@@ -46,48 +46,111 @@ trait AKSRT_Shop_Part_1 {
public function get_product_archive_view(array $args = []): array {
$taxonomy = sanitize_key((string) ($args['taxonomy'] ?? ''));
$term_id = (int) ($args['term_id'] ?? 0);
$paged = max(1, (int) ($args['paged'] ?? 1));
$per_page = 12;
$paged = max(1, (int) ($args['paged'] ?? $args['page'] ?? 1));
if (!in_array($taxonomy, ['aksrt_product_cat', 'aksrt_product_tag'], true)) {
return ['products' => [], 'term' => null, 'total' => 0, 'max_pages' => 0];
$shop_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_shop_settings() : [];
$list = is_array($shop_settings['list'] ?? null) ? $shop_settings['list'] : [];
$per_page = max(4, min(100, (int) ($args['per_page'] ?? ($list['count'] ?? 12))));
$orderby = sanitize_key((string) ($args['orderby'] ?? ($list['orderby'] ?? 'date')));
if (!in_array($orderby, ['date', 'sales', 'price_asc', 'price_desc', 'comments', 'modified'], true)) {
$orderby = 'date';
}
$paging = sanitize_key((string) ($args['paging'] ?? ($list['paging'] ?? 'number')));
if (!in_array($paging, ['number', 'ajax'], true)) {
$paging = 'number';
}
$ias_s = array_key_exists('ias_s', $args) ? !empty($args['ias_s']) : !empty($list['ias_s']);
$ias_max = max(1, min(50, (int) ($args['ias_max'] ?? ($list['ias_max'] ?? 5))));
$style = sanitize_key((string) ($list['style'] ?? 'default'));
$empty = [
'products' => [],
'term' => null,
'total' => 0,
'max_pages' => 0,
'page' => $paged,
'orderby' => $orderby,
'paging' => $paging,
'ias_s' => $ias_s,
'ias_max' => $ias_max,
'per_page' => $per_page,
'style' => $style,
'sales' => is_array($shop_settings['sales'] ?? null) ? $shop_settings['sales'] : [],
];
if (!in_array($taxonomy, ['aksrt_product_cat', 'aksrt_product_tag'], true) && empty($args['allow_all'])) {
return $empty;
}
$term = get_term($term_id, $taxonomy);
if (is_wp_error($term) || !$term) {
return ['products' => [], 'term' => null, 'total' => 0, 'max_pages' => 0];
}
$query = new WP_Query([
$query_args = [
'post_type' => 'aksrt_product',
'posts_per_page' => $per_page,
'paged' => $paged,
'post_status' => 'publish',
'tax_query' => [[
'order' => 'DESC',
'orderby' => 'date',
];
$term = null;
if ($taxonomy !== '' && $term_id > 0) {
$term = get_term($term_id, $taxonomy);
if (is_wp_error($term) || !$term) {
return $empty;
}
$query_args['tax_query'] = [[
'taxonomy' => $taxonomy,
'field' => 'term_id',
'terms' => $term_id,
]],
]);
]];
}
if ($orderby === 'sales') {
$query_args['meta_key'] = '_aksrt_sales';
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'DESC';
} elseif ($orderby === 'price_asc') {
$query_args['meta_key'] = '_aksrt_price';
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'ASC';
} elseif ($orderby === 'price_desc') {
$query_args['meta_key'] = '_aksrt_price';
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'DESC';
} elseif ($orderby === 'comments') {
$query_args['orderby'] = 'comment_count';
$query_args['order'] = 'DESC';
} elseif ($orderby === 'modified') {
$query_args['orderby'] = 'modified';
$query_args['order'] = 'DESC';
}
$query = new WP_Query($query_args);
$products = [];
while ($query->have_posts()) {
$query->the_post();
$products[] = $this->build_product_card_view(get_the_ID());
}
wp_reset_postdata();
return [
'products' => $products,
'term' => [
'id' => $term->term_id,
'name' => $term->name,
'description' => $term->description,
'count' => $term->count,
],
'term' => $term ? [
'id' => (int) $term->term_id,
'name' => (string) $term->name,
'description' => (string) $term->description,
'count' => (int) $term->count,
'taxonomy' => $taxonomy,
] : null,
'total' => (int) $query->found_posts,
'max_pages' => (int) $query->max_num_pages,
'page' => $paged,
'orderby' => $orderby,
'paging' => $paging,
'ias_s' => $ias_s,
'ias_max' => $ias_max,
'per_page' => $per_page,
'style' => $style,
'sales' => is_array($shop_settings['sales'] ?? null) ? $shop_settings['sales'] : [],
];
}