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
@@ -3,41 +3,29 @@
|
||||
* Template Name: AKSRT - Orders
|
||||
* Template Post Type: page
|
||||
*
|
||||
* Legacy standalone orders URL — redirects into user center tab (zibll-style).
|
||||
* Kept as template slug so old page assignments resolve; content lives in UC.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(home_url('/profile/'));
|
||||
wp_safe_redirect($login_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$target = function_exists('aksrt_get_user_center_url')
|
||||
? aksrt_get_user_center_url('orders')
|
||||
: home_url('/profile/?tab=orders');
|
||||
? aksrt_get_user_center_url('orders')
|
||||
: home_url('/profile/?tab=orders');
|
||||
|
||||
// Preserve filter/query from standalone page.
|
||||
$keep = [];
|
||||
foreach (['order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section'] as $key) {
|
||||
if (isset($_GET[$key]) && (string) wp_unslash($_GET[$key]) !== '') {
|
||||
$keep[$key] = sanitize_text_field(wp_unslash((string) $_GET[$key]));
|
||||
}
|
||||
}
|
||||
// Legacy ?tab=pending on standalone page → order_tab.
|
||||
if (isset($_GET['tab'])) {
|
||||
$legacy_tab = sanitize_key((string) wp_unslash($_GET['tab']));
|
||||
if ($legacy_tab !== '' && $legacy_tab !== 'orders' && !isset($keep['order_tab'])) {
|
||||
$keep['order_tab'] = $legacy_tab;
|
||||
}
|
||||
}
|
||||
if ($keep !== []) {
|
||||
$target = add_query_arg($keep, $target);
|
||||
if (!is_user_logged_in()) {
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url($target);
|
||||
wp_safe_redirect($login_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_safe_redirect($target, 302);
|
||||
$raw = [
|
||||
'status' => $_GET['order_status'] ?? '',
|
||||
'type' => $_GET['order_type'] ?? '',
|
||||
'order_number' => $_GET['order_number'] ?? '',
|
||||
'page' => $_GET['order_page'] ?? 1,
|
||||
];
|
||||
$query = \AKSRT\Payment\OrderCenterQuery::from_array($raw);
|
||||
$params = array_merge(['tab' => 'orders'], $query->url_values());
|
||||
|
||||
wp_safe_redirect(add_query_arg($params, $target), 302);
|
||||
exit;
|
||||
Reference in new issue
Block a user