feat(orders): redesign user order center
This commit is contained in:
1 parent
41506eeb3d
commit
26d307056e
10 files changed
+928
-3652
No files matched your search
@@ -17,13 +17,14 @@ function aksrt_get_order_status_labels(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page = 20, string $status = '', string $product_type = ''): array {
|
||||
function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page = 20, string $status = 'all', string $product_type = '', string $order_number = ''): array {
|
||||
$empty = [
|
||||
'items' => [],
|
||||
'total' => 0,
|
||||
'total_pages' => 1,
|
||||
'page' => 1,
|
||||
'stats' => ['total' => 0, 'pending' => 0, 'paid' => 0],
|
||||
'query' => [],
|
||||
'stats' => ['total' => 0, 'pending' => 0, 'completed' => 0],
|
||||
'product_types' => class_exists('\AKSRT\Core\DomainModel')
|
||||
? array_merge(['' => __('全部类型', 'aksrt')], \AKSRT\Core\DomainModel::order_product_type_labels())
|
||||
: [],
|
||||
@@ -38,6 +39,7 @@ function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page
|
||||
'per_page' => $per_page,
|
||||
'status' => $status,
|
||||
'product_type' => $product_type,
|
||||
'order_number' => $order_number,
|
||||
];
|
||||
|
||||
if (class_exists('\AKSRT\Payment\UserOrders')) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center panel: My Orders (embedded; zibll-style tab content).
|
||||
* User-center knowledge-payment order panel.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -10,343 +10,132 @@ defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
if ($user_id <= 0) {
|
||||
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
||||
return;
|
||||
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$per_page = 20;
|
||||
$paged = max(1, (int) ($_GET['order_page'] ?? 1));
|
||||
$tab = sanitize_key((string) ($_GET['order_tab'] ?? ($_GET['otab'] ?? '')));
|
||||
$status = sanitize_key((string) ($_GET['order_status'] ?? ''));
|
||||
$type_filter = sanitize_key((string) ($_GET['order_type'] ?? ''));
|
||||
$section = sanitize_key((string) ($_GET['section'] ?? ''));
|
||||
|
||||
// Accept legacy standalone-page tab keys.
|
||||
if ($tab === '' && isset($_GET['tab']) && sanitize_key((string) $_GET['tab']) !== 'orders') {
|
||||
// When rendered as standalone legacy include, outer tab may be status.
|
||||
$maybe = sanitize_key((string) $_GET['tab']);
|
||||
if (in_array($maybe, ['pending', 'after'], true)) {
|
||||
$tab = $maybe;
|
||||
}
|
||||
}
|
||||
|
||||
$tab_aliases = [];
|
||||
if (isset($tab_aliases[$tab])) {
|
||||
$tab = $tab_aliases[$tab];
|
||||
}
|
||||
|
||||
$tab_status_map = [
|
||||
'pending' => \AKSRT\Payment\Order::STATUS_PENDING,
|
||||
'after' => \AKSRT\Payment\Order::STATUS_REFUNDING,
|
||||
$raw_query = [
|
||||
'status' => $_GET['order_status'] ?? '',
|
||||
'type' => $_GET['order_type'] ?? '',
|
||||
'order_number' => $_GET['order_number'] ?? '',
|
||||
'page' => $_GET['order_page'] ?? 1,
|
||||
'per_page' => 20,
|
||||
];
|
||||
if ($tab !== '' && isset($tab_status_map[$tab])) {
|
||||
$status = $tab_status_map[$tab];
|
||||
}
|
||||
|
||||
$query = \AKSRT\Payment\OrderCenterQuery::from_array($raw_query);
|
||||
$orders_view = function_exists('aksrt_get_orders_page_view')
|
||||
? aksrt_get_orders_page_view($user_id, $paged, $per_page, $status, $type_filter)
|
||||
: ['items' => [], 'total' => 0, 'total_pages' => 1, 'page' => 1, 'stats' => [], 'product_types' => []];
|
||||
? aksrt_get_orders_page_view($user_id, $query->page(), $query->per_page(), $query->status(), $query->product_type(), $query->order_number())
|
||||
: ['items' => [], 'total' => 0, 'total_pages' => 1, 'page' => 1, 'stats' => [], 'product_types' => []];
|
||||
|
||||
$orders = (array) ($orders_view['items'] ?? []);
|
||||
$total_pages = max(1, (int) ($orders_view['total_pages'] ?? 1));
|
||||
$stats = is_array($orders_view['stats'] ?? null) ? $orders_view['stats'] : [];
|
||||
$orders = (array) ($orders_view['items'] ?? []);
|
||||
$stats = is_array($orders_view['stats'] ?? null) ? $orders_view['stats'] : [];
|
||||
$type_options = is_array($orders_view['product_types'] ?? null) ? $orders_view['product_types'] : [];
|
||||
if ($type_options === [] && class_exists('\AKSRT\Core\DomainModel')) {
|
||||
$type_options = array_merge(['' => __('全部类型', 'aksrt')], \AKSRT\Core\DomainModel::order_product_type_labels());
|
||||
}
|
||||
$page = max(1, (int) ($orders_view['page'] ?? 1));
|
||||
$total_pages = max(1, (int) ($orders_view['total_pages'] ?? 1));
|
||||
$status = $query->status();
|
||||
$type = $query->product_type();
|
||||
$order_number = $query->order_number();
|
||||
|
||||
$tabs = [
|
||||
'' => __('全部', 'aksrt'),
|
||||
'pending' => __('待支付', 'aksrt'),
|
||||
'after' => __('退款中', 'aksrt'),
|
||||
];
|
||||
|
||||
$base_query = ['tab' => 'orders'];
|
||||
if ($type_filter !== '') {
|
||||
$base_query['order_type'] = $type_filter;
|
||||
}
|
||||
if ($section !== '') {
|
||||
$base_query['section'] = $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build URL staying inside user center orders tab.
|
||||
*
|
||||
* @param array<string, scalar|null> $args
|
||||
*/
|
||||
$orders_url = static function (array $args = []) use ($base_query): string {
|
||||
$q = array_merge($base_query, $args);
|
||||
$base = function_exists('aksrt_get_user_center_url')
|
||||
? aksrt_get_user_center_url('orders')
|
||||
: home_url('/profile/');
|
||||
$url = remove_query_arg(
|
||||
['order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section', 'tab'],
|
||||
$base
|
||||
);
|
||||
// Always keep tab=orders.
|
||||
$q['tab'] = 'orders';
|
||||
// Map status filter to order_tab (avoid clashing with UC tab=).
|
||||
if (isset($q['tab_status'])) {
|
||||
$q['order_tab'] = $q['tab_status'];
|
||||
unset($q['tab_status']);
|
||||
}
|
||||
foreach ($q as $k => $v) {
|
||||
if ($v === null || $v === '') {
|
||||
unset($q[$k]);
|
||||
}
|
||||
}
|
||||
return add_query_arg($q, $url);
|
||||
$orders_url = static function (array $override = []) use ($status, $type, $order_number, $page): string {
|
||||
$values = array_merge([
|
||||
'order_status' => $status,
|
||||
'order_type' => $type,
|
||||
'order_number' => $order_number,
|
||||
'order_page' => $page,
|
||||
], $override);
|
||||
$base = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('orders') : home_url('/profile/');
|
||||
$values['tab'] = 'orders';
|
||||
foreach ($values as $key => $value) {
|
||||
if ($value === '' || $value === null || ($key === 'order_page' && (int) $value <= 1) || ($key === 'order_status' && $value === 'all')) {
|
||||
unset($values[$key]);
|
||||
}
|
||||
}
|
||||
return add_query_arg($values, remove_query_arg(['order_tab', 'otab', 'section'], $base));
|
||||
};
|
||||
|
||||
$pending_count = (int) ($stats['pending'] ?? 0);
|
||||
$tabs = [
|
||||
'all' => __('全部', 'aksrt'),
|
||||
'pending' => __('待支付', 'aksrt'),
|
||||
'completed' => __('已完成', 'aksrt'),
|
||||
'closed' => __('已关闭', 'aksrt'),
|
||||
];
|
||||
?>
|
||||
<div class="aksrt-orders-page uc-orders-panel" data-aksrt-order-center data-aksrt-uc-orders>
|
||||
<div class="uc-orders-panel__head flex ac jsb mb10">
|
||||
<div class="uc-orders-panel__title-wrap">
|
||||
<div class="uc-orders-panel__title font-bold em12">
|
||||
<i class="fas fa-receipt uc-orders-panel__title-icon" aria-hidden="true"></i>
|
||||
<?php esc_html_e('我的订单', 'aksrt'); ?>
|
||||
</div>
|
||||
<div class="muted-2-color em09 mt3"><?php esc_html_e('查看付费内容、会员与充值等全部订单。', 'aksrt'); ?></div>
|
||||
</div>
|
||||
<div class="aksrt-orders-page uc-orders-panel" data-aksrt-order-center>
|
||||
<header class="uc-orders-panel__head">
|
||||
<div class="uc-orders-panel__title-wrap">
|
||||
<p class="aksrt-orders-page__eyebrow"><?php esc_html_e('我的购买', 'aksrt'); ?></p>
|
||||
<div class="uc-orders-panel__title font-bold em12">
|
||||
<i class="fas fa-receipt uc-orders-panel__title-icon" aria-hidden="true"></i>
|
||||
<?php esc_html_e('我的订单', 'aksrt'); ?>
|
||||
</div>
|
||||
<p class="muted-2-color em09 mt3"><?php esc_html_e('管理已购内容、会员与账户权益。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="aksrt-orders-page__stats" data-aksrt-order-stats>
|
||||
<div class="aksrt-orders-page__stat"><span><?php esc_html_e('全部', 'aksrt'); ?></span><strong><?php echo esc_html((string) (int) ($stats['total'] ?? 0)); ?></strong></div>
|
||||
<div class="aksrt-orders-page__stat"><span><?php esc_html_e('待支付', 'aksrt'); ?></span><strong class="is-pending"><?php echo esc_html((string) (int) ($stats['pending'] ?? 0)); ?></strong></div>
|
||||
<div class="aksrt-orders-page__stat"><span><?php esc_html_e('已生效', 'aksrt'); ?></span><strong class="is-completed"><?php echo esc_html((string) (int) ($stats['completed'] ?? 0)); ?></strong></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if (!empty($stats)) : ?>
|
||||
<div class="aksrt-orders-page__stats" data-aksrt-order-stats>
|
||||
<div class="aksrt-orders-page__stat">
|
||||
<span class="aksrt-orders-page__stat-label"><?php esc_html_e('全部订单', 'aksrt'); ?></span>
|
||||
<strong class="aksrt-orders-page__stat-value"><?php echo esc_html((string) (int) ($stats['total'] ?? 0)); ?></strong>
|
||||
</div>
|
||||
<div class="aksrt-orders-page__stat">
|
||||
<span class="aksrt-orders-page__stat-label"><?php esc_html_e('待支付', 'aksrt'); ?></span>
|
||||
<strong class="aksrt-orders-page__stat-value c-red"><?php echo esc_html((string) $pending_count); ?></strong>
|
||||
</div>
|
||||
<div class="aksrt-orders-page__stat">
|
||||
<span class="aksrt-orders-page__stat-label"><?php esc_html_e('已支付', 'aksrt'); ?></span>
|
||||
<strong class="aksrt-orders-page__stat-value c-green"><?php echo esc_html((string) (int) ($stats['paid'] ?? 0)); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form class="aksrt-orders-page__search" method="get" action="<?php echo esc_url($orders_url(['order_page' => null])); ?>">
|
||||
<input type="hidden" name="tab" value="orders">
|
||||
<?php if ($status !== 'all') : ?><input type="hidden" name="order_status" value="<?php echo esc_attr($status); ?>"><?php endif; ?>
|
||||
<?php if ($type !== '') : ?><input type="hidden" name="order_type" value="<?php echo esc_attr($type); ?>"><?php endif; ?>
|
||||
<label class="screen-reader-text" for="aksrt-order-number"><?php esc_html_e('按订单号查找', 'aksrt'); ?></label>
|
||||
<i class="fas fa-search" aria-hidden="true"></i>
|
||||
<input id="aksrt-order-number" name="order_number" value="<?php echo esc_attr($order_number); ?>" maxlength="32" placeholder="<?php esc_attr_e('输入订单号开头快速查找', 'aksrt'); ?>">
|
||||
<button class="btn-primary" type="submit"><?php esc_html_e('查找', 'aksrt'); ?></button>
|
||||
<button class="aksrt-orders-page__filter-toggle" type="button" data-aksrt-orders-filter-toggle aria-expanded="false" aria-controls="aksrt-orders-filter-panel"><i class="fas fa-sliders-h" aria-hidden="true"></i> <?php esc_html_e('筛选', 'aksrt'); ?></button>
|
||||
</form>
|
||||
|
||||
<div class="aksrt-orders-page__extra-nav" data-aksrt-orders-extra-nav>
|
||||
<a href="<?php echo esc_url($orders_url(['section' => null])); ?>" class="aksrt-orders-page__extra-link<?php echo $section === '' ? ' is-active' : ''; ?>"><?php esc_html_e('订单列表', 'aksrt'); ?></a>
|
||||
<a href="<?php echo esc_url($orders_url(['section' => 'coupons'])); ?>" class="aksrt-orders-page__extra-link<?php echo $section === 'coupons' ? ' is-active' : ''; ?>"><?php esc_html_e('优惠券', 'aksrt'); ?></a>
|
||||
</div>
|
||||
<div id="aksrt-orders-filter-panel" class="aksrt-orders-page__filter-panel" data-aksrt-orders-filter-panel hidden>
|
||||
<span class="aksrt-orders-page__filter-label"><?php esc_html_e('订单类型', 'aksrt'); ?></span>
|
||||
<div class="aksrt-orders-page__type-filters">
|
||||
<?php foreach ($type_options as $key => $label) : ?>
|
||||
<a class="aksrt-orders-page__filter-chip<?php echo (string) $key === $type ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_type' => $key, 'order_page' => null])); ?>"><?php echo esc_html((string) $label); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<a class="aksrt-orders-page__clear" href="<?php echo esc_url($orders_url(['order_status' => null, 'order_type' => null, 'order_number' => null, 'order_page' => null])); ?>"><?php esc_html_e('清除条件', 'aksrt'); ?></a>
|
||||
</div>
|
||||
|
||||
<?php if ($type_options && $section === '') : ?>
|
||||
<div class="aksrt-orders-page__type-filters" data-aksrt-order-type-filters>
|
||||
<?php foreach ($type_options as $type_key => $type_label) :
|
||||
$is_type_active = (string) $type_key === (string) $type_filter;
|
||||
$type_args = [
|
||||
'order_type' => $type_key !== '' ? $type_key : null,
|
||||
'order_tab' => $tab !== '' ? $tab : null,
|
||||
'order_page' => 1,
|
||||
];
|
||||
$type_url = $orders_url($type_args);
|
||||
if ($type_key === '') {
|
||||
$type_url = remove_query_arg('order_type', $type_url);
|
||||
}
|
||||
?>
|
||||
<a href="<?php echo esc_url($type_url); ?>" class="aksrt-orders-page__filter-chip<?php echo $is_type_active ? ' is-active' : ''; ?>">
|
||||
<?php echo esc_html((string) $type_label); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<nav class="aksrt-orders-page__tabs" aria-label="<?php esc_attr_e('订单状态', 'aksrt'); ?>">
|
||||
<?php foreach ($tabs as $key => $label) : ?>
|
||||
<a class="aksrt-orders-page__tab<?php echo $status === $key ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_status' => $key, 'order_page' => null])); ?>">
|
||||
<?php echo esc_html($label); ?>
|
||||
<?php if ($key === 'pending' && !empty($stats['pending'])) : ?><span class="aksrt-orders-page__tab-badge"><?php echo esc_html((string) $stats['pending']); ?></span><?php endif; ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
|
||||
<?php if ($section === '') : ?>
|
||||
<div class="aksrt-orders-page__tabs user-order-tabs">
|
||||
<?php foreach ($tabs as $tab_key => $tab_label) :
|
||||
$is_active = $tab === $tab_key;
|
||||
$tab_url = $tab_key !== ''
|
||||
? $orders_url(['order_tab' => $tab_key, 'order_page' => 1])
|
||||
: remove_query_arg(['order_tab', 'otab', 'order_status', 'order_page'], $orders_url());
|
||||
?>
|
||||
<a href="<?php echo esc_url($tab_url); ?>" class="aksrt-orders-page__tab<?php echo $is_active ? ' is-active' : ''; ?>" data-order-tab="<?php echo esc_attr((string) $tab_key); ?>">
|
||||
<?php echo esc_html($tab_label); ?>
|
||||
<?php if ($tab_key === 'pending' && $pending_count > 0) : ?>
|
||||
<span class="aksrt-orders-page__tab-badge"><?php echo esc_html((string) $pending_count); ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($orders !== []) : ?>
|
||||
<div class="aksrt-orders-page__list" data-aksrt-order-list>
|
||||
<?php foreach ($orders as $order) :
|
||||
$number = (string) ($order['order_number'] ?? '');
|
||||
$actions = (array) ($order['actions'] ?? []);
|
||||
$amount = !empty($order['is_points'])
|
||||
? esc_html((string) ($order['currency_symbol'] ?? __('积分', 'aksrt')) . ' ' . (string) (int) round((float) ($order['amount'] ?? 0)))
|
||||
: '¥' . esc_html(number_format((float) ($order['amount'] ?? 0), 2));
|
||||
?>
|
||||
<article class="aksrt-orders-page__card" data-aksrt-order-card="<?php echo esc_attr($number); ?>" data-order-status="<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>">
|
||||
<div class="aksrt-orders-page__card-rail"><span><?php echo esc_html((string) ($order['product_type_label'] ?? '')); ?></span><time><?php echo esc_html((string) ($order['created_at'] ?? '')); ?></time><span class="aksrt-orders-page__card-status is-<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>"><?php echo esc_html((string) ($order['status_label'] ?? '')); ?></span></div>
|
||||
<div class="aksrt-orders-page__card-main">
|
||||
<?php if (!empty($order['image'])) : ?><img class="aksrt-orders-page__card-img" src="<?php echo esc_url((string) $order['image']); ?>" alt=""><?php else : ?><div class="aksrt-orders-page__card-art" aria-hidden="true"><i class="fas fa-book-open"></i></div><?php endif; ?>
|
||||
<div class="aksrt-orders-page__card-copy"><h3><?php echo esc_html((string) ($order['product_name'] ?? __('订单', 'aksrt'))); ?></h3><p><?php printf(esc_html__('订单号 %s', 'aksrt'), esc_html($number)); ?></p></div>
|
||||
<div class="aksrt-orders-page__card-value"><strong><?php echo $amount; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong><span><?php esc_html_e('实付', 'aksrt'); ?></span></div>
|
||||
</div>
|
||||
<footer class="aksrt-orders-page__card-actions">
|
||||
<?php if (!empty($order['time_left'])) : ?><span class="aksrt-orders-page__countdown" data-aksrt-order-countdown="<?php echo esc_attr((string) $order['time_left']); ?>"></span><?php endif; ?>
|
||||
<button class="btn-outline" type="button" data-aksrt-order-detail="<?php echo esc_attr($number); ?>"><?php esc_html_e('订单详情', 'aksrt'); ?></button>
|
||||
<?php if (!empty($actions['can_cancel'])) : ?><button class="btn-ghost" type="button" data-aksrt-order-cancel="<?php echo esc_attr($number); ?>"><?php esc_html_e('关闭订单', 'aksrt'); ?></button><?php endif; ?>
|
||||
<?php if (!empty($actions['can_pay'])) : ?><button class="btn-primary" type="button" data-aksrt-order-pay="<?php echo esc_attr($number); ?>" data-aksrt-order-method="<?php echo esc_attr((string) ($order['payment_method']['value'] ?? '')); ?>"><?php esc_html_e('继续支付', 'aksrt'); ?></button><?php endif; ?>
|
||||
<?php if (!empty($actions['can_open'])) : ?><a class="btn-primary is-entitlement" href="<?php echo esc_url((string) ($order['permalink'] ?? '')); ?>"><?php echo esc_html((string) ($order['entitlement_label'] ?? __('打开已购内容', 'aksrt'))); ?></a><?php endif; ?>
|
||||
</footer>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($total_pages > 1) : ?><nav class="aksrt-orders-page__pagination" aria-label="<?php esc_attr_e('订单分页', 'aksrt'); ?>"><?php for ($index = 1; $index <= $total_pages; $index++) : ?><a class="aksrt-orders-page__page-chip<?php echo $index === $page ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_page' => $index])); ?>"><?php echo esc_html((string) $index); ?></a><?php endfor; ?></nav><?php endif; ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-orders-page__empty"><i class="fas fa-receipt" aria-hidden="true"></i><h3><?php echo esc_html($order_number !== '' || $type !== '' || $status !== 'all' ? __('没有匹配的订单', 'aksrt') : __('还没有购买记录', 'aksrt')); ?></h3><p><?php echo esc_html($order_number !== '' || $type !== '' || $status !== 'all' ? __('换个条件试试,或清除当前筛选。', 'aksrt') : __('购买内容或开通权益后,订单会出现在这里。', 'aksrt')); ?></p><?php if ($order_number !== '' || $type !== '' || $status !== 'all') : ?><a class="btn-outline" href="<?php echo esc_url($orders_url(['order_status' => null, 'order_type' => null, 'order_number' => null, 'order_page' => null])); ?>"><?php esc_html_e('清除条件', 'aksrt'); ?></a><?php endif; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($section === '' && !empty($orders)) : ?>
|
||||
<div class="aksrt-orders-page__list">
|
||||
<?php foreach ($orders as $order) :
|
||||
$on = (string) ($order['order_number'] ?? '');
|
||||
$os = (string) ($order['status'] ?? '');
|
||||
$items = $order['items'] ?? [];
|
||||
$ptype = (string) ($order['product_type'] ?? '');
|
||||
$is_points = !empty($order['is_points']);
|
||||
$symbol = (string) ($order['currency_symbol'] ?? '¥');
|
||||
$actions = is_array($order['actions'] ?? null) ? $order['actions'] : [];
|
||||
$amount_display = $is_points
|
||||
? esc_html($symbol) . ' ' . esc_html((string) (int) round((float) ($order['amount'] ?? 0)))
|
||||
: '¥' . esc_html(number_format((float) ($order['amount'] ?? 0), 2));
|
||||
?>
|
||||
<article class="aksrt-orders-page__card" data-aksrt-order-card="<?php echo esc_attr($on); ?>" data-product-type="<?php echo esc_attr($ptype); ?>" data-order-status="<?php echo esc_attr($os); ?>">
|
||||
<div class="aksrt-orders-page__card-head">
|
||||
<?php if ((string) ($order['product_type_label'] ?? '') !== '') : ?>
|
||||
<span class="aksrt-orders-page__card-type"><?php echo esc_html((string) $order['product_type_label']); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="aksrt-orders-page__card-number"><?php echo esc_html($on); ?></span>
|
||||
<time class="aksrt-orders-page__card-time"><?php echo esc_html((string) ($order['created_at'] ?? '')); ?></time>
|
||||
<span class="aksrt-orders-page__card-status"><?php echo esc_html((string) ($order['status_label'] ?? '')); ?></span>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-orders-page__card-items">
|
||||
<?php if (!empty($items) && is_array($items)) : ?>
|
||||
<?php foreach ($items as $item) :
|
||||
$item_image = (string) ($item['image'] ?? '');
|
||||
if ($item_image === '') {
|
||||
$item_image = (string) ($order['image'] ?? '');
|
||||
}
|
||||
?>
|
||||
<div class="aksrt-orders-page__card-item<?php echo $item_image === '' ? ' aksrt-orders-page__card-item--no-image' : ''; ?>" data-product-id="<?php echo esc_attr((string) ($item['product_id'] ?? 0)); ?>">
|
||||
<?php if ($item_image !== '') : ?>
|
||||
<img src="<?php echo esc_url($item_image); ?>" alt="" class="aksrt-orders-page__card-img">
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-orders-page__card-item-info">
|
||||
<span class="aksrt-orders-page__card-item-title"><?php echo esc_html((string) ($item['product_title'] ?? $order['product_name'] ?? '')); ?></span>
|
||||
<?php if (!empty($item['options_label'])) : ?>
|
||||
<small class="aksrt-orders-page__card-item-opts"><?php echo esc_html((string) $item['options_label']); ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="aksrt-orders-page__card-item-price">
|
||||
<strong><?php
|
||||
if ($is_points) {
|
||||
echo esc_html($symbol . ' ' . (string) (int) round((float) ($item['pay_price'] ?? $item['unit_price'] ?? 0)));
|
||||
} else {
|
||||
echo '¥' . esc_html(number_format((float) ($item['pay_price'] ?? $item['unit_price'] ?? 0), 2));
|
||||
}
|
||||
?></strong>
|
||||
<span>×<?php echo esc_html((string) ($item['quantity'] ?? 1)); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php $order_image = (string) ($order['image'] ?? ''); ?>
|
||||
<div class="aksrt-orders-page__card-item<?php echo $order_image === '' ? ' aksrt-orders-page__card-item--no-image' : ''; ?>" data-product-id="<?php echo esc_attr((string) ($order['product_id'] ?? 0)); ?>">
|
||||
<?php if ($order_image !== '') : ?>
|
||||
<img src="<?php echo esc_url($order_image); ?>" alt="" class="aksrt-orders-page__card-img">
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-orders-page__card-item-info">
|
||||
<span class="aksrt-orders-page__card-item-title"><?php echo esc_html((string) ($order['product_name'] ?? __('订单', 'aksrt'))); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-orders-page__card-item-price">
|
||||
<strong><?php echo $amount_display; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-orders-page__card-summary">
|
||||
<span><?php esc_html_e('合计', 'aksrt'); ?></span>
|
||||
<strong><?php echo $amount_display; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
|
||||
<?php if ((float) ($order['discount'] ?? 0) > 0 && !$is_points) : ?>
|
||||
<small>(<?php
|
||||
printf(
|
||||
/* translators: %s: discount amount */
|
||||
esc_html__('已优惠 ¥%s', 'aksrt'),
|
||||
number_format((float) $order['discount'], 2)
|
||||
);
|
||||
?>)</small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($order['shipping_records'])) : ?>
|
||||
<div class="aksrt-orders-page__timeline" data-aksrt-timeline>
|
||||
<h4 class="aksrt-orders-page__timeline-toggle" data-aksrt-toggle-timeline>
|
||||
<i class="fas fa-truck"></i> <?php esc_html_e('物流信息', 'aksrt'); ?> <i class="fas fa-chevron-down"></i>
|
||||
</h4>
|
||||
<div class="aksrt-orders-page__timeline-body" hidden>
|
||||
<?php foreach ((array) ($order['timeline'] ?? []) as $tl) : ?>
|
||||
<div class="aksrt-orders-page__timeline-item">
|
||||
<time><?php echo esc_html((string) ($tl['time'] ?? '')); ?></time>
|
||||
<span><?php echo esc_html((string) ($tl['label'] ?? '')); ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-orders-page__card-actions">
|
||||
<?php if (!empty($order['time_left'])) : ?>
|
||||
<span class="aksrt-orders-page__countdown" data-aksrt-order-countdown="<?php echo esc_attr((string) $order['time_left']); ?>">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %d: seconds */
|
||||
esc_html__('%d秒后关闭', 'aksrt'),
|
||||
(int) $order['time_left']
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn-outline btn-sm" data-aksrt-order-detail="<?php echo esc_attr($on); ?>"><?php esc_html_e('查看', 'aksrt'); ?></button>
|
||||
<?php if (!empty($actions['can_cancel'])) : ?>
|
||||
<button type="button" class="btn-ghost btn-sm" data-aksrt-order-cancel="<?php echo esc_attr($on); ?>"><?php esc_html_e('取消', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($actions['can_pay'])) : ?>
|
||||
<button type="button" class="btn-primary btn-sm" data-aksrt-order-pay="<?php echo esc_attr($on); ?>" data-aksrt-order-method="<?php echo esc_attr((string) ($order['payment_method']['value'] ?? '')); ?>"><?php esc_html_e('去支付', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($actions['can_view_product']) && !empty($order['permalink'])) : ?>
|
||||
<a class="btn-ghost btn-sm" href="<?php echo esc_url((string) $order['permalink']); ?>"><?php
|
||||
echo (class_exists('\AKSRT\Core\DomainModel') && $ptype === \AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE)
|
||||
? esc_html__('去内容', 'aksrt')
|
||||
: esc_html__('查看', 'aksrt');
|
||||
?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($total_pages > 1) : ?>
|
||||
<div class="aksrt-orders-page__pagination">
|
||||
<?php for ($i = 1; $i <= $total_pages; $i++) :
|
||||
$page_url = $orders_url(array_filter([
|
||||
'order_tab' => $tab !== '' ? $tab : null,
|
||||
'order_page' => $i,
|
||||
], static fn($v) => $v !== null && $v !== ''));
|
||||
?>
|
||||
<?php if ($i === $paged) : ?>
|
||||
<span class="aksrt-orders-page__page-chip is-active"><?php echo esc_html((string) $i); ?></span>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url($page_url); ?>" class="aksrt-orders-page__page-chip"><?php echo esc_html((string) $i); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($section === '') : ?>
|
||||
<div class="aksrt-orders-page__empty">
|
||||
<i class="fas fa-receipt" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e('暂无订单记录', 'aksrt'); ?></p>
|
||||
<p class="aksrt-orders-page__empty-hint muted-2-color em09"><?php esc_html_e('开通会员或购买付费内容,订单会出现在这里。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Order detail modal -->
|
||||
<div class="aksrt-modal" data-aksrt-order-detail-modal hidden>
|
||||
<div class="aksrt-modal__overlay" data-aksrt-order-detail-close></div>
|
||||
<div class="aksrt-modal__dialog aksrt-order-detail-dialog" role="dialog" aria-modal="true" aria-labelledby="aksrt-order-detail-title">
|
||||
<div class="aksrt-modal__header">
|
||||
<h3 id="aksrt-order-detail-title"><?php esc_html_e('订单详情', 'aksrt'); ?></h3>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-order-detail-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">×</button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body" data-aksrt-order-detail-body>
|
||||
<p class="muted-2-color"><?php esc_html_e('加载中…', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="aksrt-modal__footer" data-aksrt-order-detail-footer></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($section === 'coupons') : ?>
|
||||
<section class="aksrt-orders-page__coupons" data-aksrt-coupon-wallet>
|
||||
<h2><?php esc_html_e('优惠券', 'aksrt'); ?></h2>
|
||||
<div class="aksrt-coupon-wallet" data-aksrt-coupon-wallet-list>
|
||||
<p class="muted-2-color"><?php esc_html_e('加载中…', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-modal" data-aksrt-order-detail-modal hidden><div class="aksrt-modal__overlay" data-aksrt-order-detail-close></div><section class="aksrt-modal__dialog aksrt-order-detail-dialog" role="dialog" aria-modal="true" aria-labelledby="aksrt-order-detail-title"><header class="aksrt-modal__header"><h3 id="aksrt-order-detail-title"><?php esc_html_e('订单详情', 'aksrt'); ?></h3><button class="aksrt-modal__close" type="button" data-aksrt-order-detail-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">×</button></header><div class="aksrt-modal__body" data-aksrt-order-detail-body></div><footer class="aksrt-modal__footer" data-aksrt-order-detail-footer></footer></section></div>
|
||||
</div>
|
||||
Reference in new issue
Block a user