feat(orders): embed My Orders inside user center (zibll-style)
Register UC panel tab=orders with full order list/actions UI; route aksrt_get_orders_page_url and /orders template to profile?tab=orders; enqueue order assets when the UC orders tab is active.
This commit is contained in:
1 parent
dae85f0198
commit
354a1072ef
8 files changed
+598
-464
No files matched your search
@@ -666,8 +666,15 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
||||
}
|
||||
}
|
||||
|
||||
// 订单中心页
|
||||
if (is_page_template('templates/pages/page-orders.php') || (bool) get_query_var('aksrt_orders')) {
|
||||
// 订单中心:独立页 / 虚拟 rewrite / 用户中心 tab=orders
|
||||
$is_orders_surface = is_page_template('templates/pages/page-orders.php')
|
||||
|| (bool) get_query_var('aksrt_orders')
|
||||
|| (
|
||||
(function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page())
|
||||
&& isset($_GET['tab'])
|
||||
&& sanitize_key((string) wp_unslash($_GET['tab'])) === 'orders'
|
||||
);
|
||||
if ($is_orders_surface) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-orders',
|
||||
$base_uri . '/assets/css/routes/orders.css',
|
||||
|
||||
@@ -71,6 +71,12 @@ class Center {
|
||||
'priority' => 45,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'orders' => [
|
||||
'label' => __('我的订单', 'aksrt'),
|
||||
'icon' => 'receipt',
|
||||
'priority' => 48,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'credits' => [
|
||||
'label' => class_exists('\AKSRT\Settings\Settings')
|
||||
? sprintf(__('我的%s', 'aksrt'), \AKSRT\Settings\Settings::get_currency_name())
|
||||
@@ -104,7 +110,7 @@ class Center {
|
||||
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
||||
|
||||
// Follow configured order; always auto-include VIP/credits when feature on.
|
||||
// Follow configured order; always auto-include VIP/orders/credits when feature on.
|
||||
$order = $configured;
|
||||
if ($vip_on && !in_array('vip', $order, true)) {
|
||||
$insert_at = count($order);
|
||||
@@ -117,6 +123,24 @@ class Center {
|
||||
}
|
||||
array_splice($order, $insert_at, 0, ['vip']);
|
||||
}
|
||||
// Orders panel: always available when payment/shop stack exists (UserOrders or Shop).
|
||||
$orders_on = class_exists('\AKSRT\Payment\UserOrders')
|
||||
|| class_exists('\AKSRT\Payment\Order')
|
||||
|| class_exists('\AKSRT\Shop\Shop');
|
||||
if ($orders_on && !in_array('orders', $order, true)) {
|
||||
$insert_at = count($order);
|
||||
foreach (['vip', 'credits', 'favorites'] as $anchor) {
|
||||
$idx = array_search($anchor, $order, true);
|
||||
if ($idx !== false) {
|
||||
$insert_at = (int) $idx + ($anchor === 'vip' ? 1 : 0);
|
||||
if ($anchor !== 'vip') {
|
||||
$insert_at = (int) $idx + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_splice($order, $insert_at, 0, ['orders']);
|
||||
}
|
||||
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
|
||||
$order[] = 'credits';
|
||||
}
|
||||
@@ -134,6 +158,9 @@ class Center {
|
||||
if ($key === 'vip' && !$vip_on) {
|
||||
continue;
|
||||
}
|
||||
if ($key === 'orders' && !$orders_on) {
|
||||
continue;
|
||||
}
|
||||
$panel = $definitions[$key];
|
||||
if ($key === 'credits' && $balance_on) {
|
||||
$panel['label'] = __('我的资产', 'aksrt');
|
||||
|
||||
Reference in new issue
Block a user