feat: remove shop feature (Phase 2)
Delete all shop domain classes, controllers, schema builders, templates, JS/CSS, admin SPA pages, and shop-only payment classes (Shipping, AfterSale, Discount). Remove shop-only DB table definitions (product_variant, after_sale, order_shipping, card_key) from migrator and add their DROP to uninstall.php. Clean up shared files: - Remove aksrt_product CPT + taxonomies from Setup.php - Remove shop rewrite rules/query vars/template redirect from SetupPart2.php - Remove shop widget areas from SetupPart1.php - Remove shop enqueues from ScriptsPart1b.php - Remove sepakerator-aksrt-shop from SetupPart2.php - Remove get_shop_settings facade (delete ForumShop.php, clean DomainGroups.php) - Remove ORDER_PRODUCT_SHOP constant from DomainModel.php - Remove Shop::class fallback branches from UserOrders.php, OrderCenterRest.php - Remove shipping/after-sale branches from OrderRepositoryAdmin.php, PayMenus.php, PayOrders.php - Remove shop product widgets from widgets-register.php - Remove cart page from template-registry.php, routing.php, ScriptsPart2.php - Remove cart UI from sidebar-nav.php, profile-orders.php, sidebar-orders.php - Clean up order-center.js (remove rebuy/cartUrl/receipt/after-sale handlers) - Remove aksrt_get_cart_page_url/product_page/product_edit from transactions.php - Clean up aksrt_product_cat references in Coupon.php, PayCoupons.php Shared payment/order/credits/content-pay stack fully retained.
This commit is contained in:
1 parent
2bbd7c01a3
commit
1d2505356e
103 files changed
+46
-21267
No files matched your search
@@ -1,292 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Cart
|
||||
* Template Post Type: page
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
wp_safe_redirect($login_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$cart_view = function_exists('aksrt_get_cart_page_view')
|
||||
? aksrt_get_cart_page_view(get_current_user_id())
|
||||
: [
|
||||
'payment_methods' => [],
|
||||
'shipping_methods' => [],
|
||||
'address_book' => [],
|
||||
'coupon_enabled' => false,
|
||||
'currency_symbol' => '¥',
|
||||
'pending_orders' => [],
|
||||
];
|
||||
|
||||
$pending_orders = is_array($cart_view['pending_orders'] ?? null) ? $cart_view['pending_orders'] : [];
|
||||
$shipping_methods = is_array($cart_view['shipping_methods'] ?? null) ? array_values($cart_view['shipping_methods']) : [];
|
||||
$payment_methods = is_array($cart_view['payment_methods'] ?? null) ? array_values($cart_view['payment_methods']) : [];
|
||||
$address_book = is_array($cart_view['address_book'] ?? null) ? $cart_view['address_book'] : [];
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
<?php if (is_active_sidebar('shop_cart_top_fluid')) : ?>
|
||||
<div class="aksrt-fluid-widget aksrt-fluid-widget--shop"><?php dynamic_sidebar('shop_cart_top_fluid'); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div
|
||||
class="aksrt-cart-page container"
|
||||
data-aksrt-cart-page
|
||||
data-currency-symbol="<?php echo esc_attr((string) ($cart_view['currency_symbol'] ?? '¥')); ?>"
|
||||
data-coupon-enabled="<?php echo !empty($cart_view['coupon_enabled']) ? '1' : '0'; ?>"
|
||||
>
|
||||
<?php
|
||||
if (function_exists('aksrt_render_commerce_page_header')) {
|
||||
aksrt_render_commerce_page_header([
|
||||
'title' => __('购物车', 'aksrt'),
|
||||
'subtitle' => __('在下单前确认地址、运费、优惠券和支付方式。', 'aksrt'),
|
||||
'active' => 'cart',
|
||||
]);
|
||||
}
|
||||
?>
|
||||
<div class="aksrt-cart-page__header">
|
||||
<?php if (!empty($pending_orders)) : ?>
|
||||
<div class="aksrt-cart-page__pending">
|
||||
<span class="aksrt-cart-page__pending-label"><?php esc_html_e('待支付订单', 'aksrt'); ?></span>
|
||||
<div class="aksrt-cart-page__pending-list">
|
||||
<?php foreach ($pending_orders as $pending_order) : ?>
|
||||
<button
|
||||
type="button"
|
||||
class="aksrt-cart-page__pending-chip"
|
||||
data-aksrt-resume-order="<?php echo esc_attr((string) ($pending_order['order_number'] ?? '')); ?>"
|
||||
>
|
||||
<?php echo esc_html((string) ($pending_order['order_number'] ?? '')); ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-cart-page__layout">
|
||||
<section class="aksrt-cart-page__main">
|
||||
<div class="aksrt-cart-page__panel">
|
||||
<div class="aksrt-cart-page__panel-head">
|
||||
<h2><?php esc_html_e('商品清单', 'aksrt'); ?></h2>
|
||||
<button type="button" class="btn-ghost btn-sm" data-aksrt-clear-cart><?php esc_html_e('清空购物车', 'aksrt'); ?></button>
|
||||
</div>
|
||||
<div class="aksrt-cart-page__items" data-aksrt-cart-items>
|
||||
<div class="aksrt-cart-page__empty">
|
||||
<i class="fas fa-shopping-cart" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e('购物车为空,去商品页添加想购买的内容。', 'aksrt'); ?></p>
|
||||
<a href="<?php echo esc_url(home_url('/')); ?>" class="btn-outline btn-sm"><?php esc_html_e('继续浏览', 'aksrt'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-cart-page__grid">
|
||||
<section class="aksrt-cart-page__panel">
|
||||
<div class="aksrt-cart-page__panel-head">
|
||||
<h2><?php esc_html_e('收货地址', 'aksrt'); ?></h2>
|
||||
<button type="button" class="btn-ghost btn-sm" data-aksrt-address-add>
|
||||
<i class="fas fa-plus" aria-hidden="true"></i> <?php esc_html_e('新增地址', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="aksrt-cart-page__option-list" data-aksrt-address-list>
|
||||
<?php if (empty($address_book)) : ?>
|
||||
<div class="aksrt-cart-page__address-empty" data-aksrt-address-empty>
|
||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e('暂无收货地址,请先新增。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($address_book as $index => $address) : ?>
|
||||
<div class="aksrt-cart-page__option-card aksrt-cart-page__address-card" data-aksrt-address-card="<?php echo esc_attr((string) ($address['id'] ?? 0)); ?>">
|
||||
<label class="aksrt-cart-page__address-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="aksrt_cart_address"
|
||||
value="<?php echo esc_attr((string) ($address['id'] ?? 0)); ?>"
|
||||
<?php checked($index === 0 || !empty($address['is_default'])); ?>
|
||||
>
|
||||
<span class="aksrt-cart-page__option-body">
|
||||
<strong>
|
||||
<?php echo esc_html((string) ($address['name'] ?? '')); ?>
|
||||
<?php if (!empty($address['is_default'])) : ?>
|
||||
<span class="aksrt-cart-page__default-tag"><?php esc_html_e('默认', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
</strong>
|
||||
<span><?php echo esc_html((string) ($address['phone'] ?? '')); ?></span>
|
||||
<span><?php echo esc_html((string) ($address['full_text'] ?? '')); ?></span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="aksrt-cart-page__address-actions">
|
||||
<button type="button" class="btn-ghost btn-xs" data-aksrt-address-edit="<?php echo esc_attr((string) ($address['id'] ?? 0)); ?>"><?php esc_html_e('编辑', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-ghost btn-xs" data-aksrt-address-delete="<?php echo esc_attr((string) ($address['id'] ?? 0)); ?>"><?php esc_html_e('删除', 'aksrt'); ?></button>
|
||||
<?php if (empty($address['is_default'])) : ?>
|
||||
<button type="button" class="btn-ghost btn-xs" data-aksrt-address-set-default="<?php echo esc_attr((string) ($address['id'] ?? 0)); ?>"><?php esc_html_e('设为默认', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Address Editor Modal -->
|
||||
<div class="aksrt-modal" data-aksrt-address-modal hidden>
|
||||
<div class="aksrt-modal__overlay"></div>
|
||||
<div class="aksrt-modal__dialog">
|
||||
<div class="aksrt-modal__header">
|
||||
<h3 data-aksrt-address-modal-title><?php esc_html_e('新增地址', 'aksrt'); ?></h3>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-address-modal-close>×</button>
|
||||
</div>
|
||||
<form class="aksrt-modal__body" data-aksrt-address-form>
|
||||
<input type="hidden" name="address_id" value="">
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('收货人', 'aksrt'); ?> *</label>
|
||||
<input type="text" name="name" class="aksrt-cart-page__input" required maxlength="50">
|
||||
</div>
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('手机号', 'aksrt'); ?> *</label>
|
||||
<input type="tel" name="phone" class="aksrt-cart-page__input" required maxlength="20">
|
||||
</div>
|
||||
<div class="aksrt-cart-page__field-row">
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('省份', 'aksrt'); ?></label>
|
||||
<input type="text" name="province" class="aksrt-cart-page__input" maxlength="50">
|
||||
</div>
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('城市', 'aksrt'); ?></label>
|
||||
<input type="text" name="city" class="aksrt-cart-page__input" maxlength="50">
|
||||
</div>
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('区/县', 'aksrt'); ?></label>
|
||||
<input type="text" name="district" class="aksrt-cart-page__input" maxlength="50">
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-cart-page__field">
|
||||
<label><?php esc_html_e('详细地址', 'aksrt'); ?> *</label>
|
||||
<input type="text" name="address" class="aksrt-cart-page__input" required maxlength="200">
|
||||
</div>
|
||||
<label class="aksrt-cart-page__checkbox">
|
||||
<input type="checkbox" name="is_default" value="1">
|
||||
<span><?php esc_html_e('设为默认地址', 'aksrt'); ?></span>
|
||||
</label>
|
||||
<div class="aksrt-modal__footer">
|
||||
<button type="button" class="btn-ghost" data-aksrt-address-modal-close><?php esc_html_e('取消', 'aksrt'); ?></button>
|
||||
<button type="submit" class="btn-primary"><?php esc_html_e('保存地址', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="aksrt-cart-page__panel">
|
||||
<div class="aksrt-cart-page__panel-head">
|
||||
<h2><?php esc_html_e('配送与支付', 'aksrt'); ?></h2>
|
||||
</div>
|
||||
<div class="aksrt-cart-page__option-columns">
|
||||
<div>
|
||||
<h3 class="aksrt-cart-page__mini-title"><?php esc_html_e('配送方式', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-cart-page__option-list" data-aksrt-shipping-list>
|
||||
<?php foreach ($shipping_methods as $index => $method) : ?>
|
||||
<label class="aksrt-cart-page__option-card">
|
||||
<input
|
||||
type="radio"
|
||||
name="aksrt_cart_shipping"
|
||||
value="<?php echo esc_attr((string) ($method['value'] ?? '')); ?>"
|
||||
<?php checked($index === 0); ?>
|
||||
>
|
||||
<span class="aksrt-cart-page__option-body">
|
||||
<strong><?php echo esc_html((string) ($method['label'] ?? '')); ?></strong>
|
||||
<span><?php echo esc_html((string) ($method['description'] ?? '')); ?></span>
|
||||
</span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 class="aksrt-cart-page__mini-title"><?php esc_html_e('支付方式', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-cart-page__option-list" data-aksrt-payment-list>
|
||||
<?php foreach ($payment_methods as $index => $method) : ?>
|
||||
<label class="aksrt-cart-page__option-card">
|
||||
<input
|
||||
type="radio"
|
||||
name="aksrt_cart_payment"
|
||||
value="<?php echo esc_attr((string) ($method['value'] ?? '')); ?>"
|
||||
<?php checked($index === 0); ?>
|
||||
>
|
||||
<span class="aksrt-cart-page__option-body">
|
||||
<strong><?php echo esc_html((string) ($method['label'] ?? '')); ?></strong>
|
||||
<span><?php echo esc_html((string) ($method['description'] ?? '')); ?></span>
|
||||
</span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="aksrt-cart-page__panel">
|
||||
<div class="aksrt-cart-page__panel-head">
|
||||
<h2><?php esc_html_e('优惠与备注', 'aksrt'); ?></h2>
|
||||
</div>
|
||||
<div class="aksrt-cart-page__coupon-box">
|
||||
<label class="aksrt-cart-page__field">
|
||||
<span><?php esc_html_e('优惠券', 'aksrt'); ?></span>
|
||||
<div class="aksrt-cart-page__coupon-row">
|
||||
<input type="text" class="aksrt-cart-page__input" data-aksrt-coupon-code placeholder="<?php esc_attr_e('输入优惠码后试算', 'aksrt'); ?>">
|
||||
<button type="button" class="btn-outline btn-sm" data-aksrt-preview-checkout><?php esc_html_e('应用并试算', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</label>
|
||||
<p class="aksrt-cart-page__hint" data-aksrt-preview-message><?php esc_html_e('试算后会展示优惠抵扣、运费和最终应付金额。', 'aksrt'); ?></p>
|
||||
|
||||
<label class="aksrt-cart-page__field">
|
||||
<span><?php esc_html_e('订单备注', 'aksrt'); ?></span>
|
||||
<textarea class="aksrt-cart-page__textarea" data-aksrt-customer-note rows="4" placeholder="<?php esc_attr_e('例如发票要求、发货备注等。', 'aksrt'); ?>"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<aside class="aksrt-cart-page__sidebar">
|
||||
<section class="aksrt-cart-page__panel aksrt-cart-page__summary">
|
||||
<div class="aksrt-cart-page__panel-head">
|
||||
<h2><?php esc_html_e('订单摘要', 'aksrt'); ?></h2>
|
||||
</div>
|
||||
<dl class="aksrt-cart-page__summary-list">
|
||||
<div>
|
||||
<dt><?php esc_html_e('商品小计', 'aksrt'); ?></dt>
|
||||
<dd data-aksrt-summary-subtotal>¥0.00</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt><?php esc_html_e('运费', 'aksrt'); ?></dt>
|
||||
<dd data-aksrt-summary-shipping>¥0.00</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt><?php esc_html_e('优惠抵扣', 'aksrt'); ?></dt>
|
||||
<dd data-aksrt-summary-discount>-¥0.00</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div class="aksrt-cart-page__summary-total">
|
||||
<span><?php esc_html_e('应付总额', 'aksrt'); ?></span>
|
||||
<strong data-aksrt-summary-total>¥0.00</strong>
|
||||
</div>
|
||||
<button type="button" class="btn-primary btn-lg aksrt-cart-page__submit" data-aksrt-create-order disabled>
|
||||
<?php esc_html_e('创建订单', 'aksrt'); ?>
|
||||
</button>
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php if (is_active_sidebar('shop_cart_bottom_fluid')) : ?>
|
||||
<div class="aksrt-fluid-widget aksrt-fluid-widget--shop"><?php dynamic_sidebar('shop_cart_bottom_fluid'); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,218 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Product Edit
|
||||
* Template Post Type: page
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
wp_safe_redirect($login_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$shop_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_shop_settings() : [];
|
||||
if (empty($shop_settings['enabled'])) {
|
||||
wp_safe_redirect(home_url('/'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$product_id = (int) ($_GET['product_id'] ?? 0);
|
||||
$edit_view = function_exists('aksrt_get_product_edit_page_view')
|
||||
? aksrt_get_product_edit_page_view(get_current_user_id(), $product_id)
|
||||
: ['allowed' => false, 'is_edit' => false, 'product' => [], 'taxonomy' => ['categories' => [], 'tags' => []], 'shipping_modes' => [], 'status_options' => []];
|
||||
|
||||
$product = (array) ($edit_view['product'] ?? []);
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div
|
||||
class="aksrt-product-editor container"
|
||||
data-aksrt-product-editor
|
||||
data-product-id="<?php echo esc_attr((string) ($product['id'] ?? 0)); ?>"
|
||||
data-is-edit="<?php echo !empty($edit_view['is_edit']) ? '1' : '0'; ?>"
|
||||
>
|
||||
<?php if (empty($edit_view['allowed'])) : ?>
|
||||
<div class="aksrt-product-editor__empty">
|
||||
<i class="fas fa-lock" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e('你没有权限编辑该商品。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-product-editor__header">
|
||||
<div>
|
||||
<h1 class="aksrt-product-editor__title">
|
||||
<?php echo !empty($edit_view['is_edit']) ? esc_html__('编辑商品', 'aksrt') : esc_html__('发布商品', 'aksrt'); ?>
|
||||
</h1>
|
||||
<p class="aksrt-product-editor__subtitle"><?php esc_html_e('管理主图、图集、分类标签、发货方式、运费和售后说明。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="aksrt-product-editor__layout" data-aksrt-product-form>
|
||||
<section class="aksrt-product-editor__main">
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('基础信息', 'aksrt'); ?></h2>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('商品名称', 'aksrt'); ?></span>
|
||||
<input type="text" name="title" class="aksrt-product-editor__input" value="<?php echo esc_attr((string) ($product['title'] ?? '')); ?>" required>
|
||||
</label>
|
||||
|
||||
<div class="aksrt-product-editor__columns">
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('价格', 'aksrt'); ?></span>
|
||||
<input type="number" name="price" class="aksrt-product-editor__input" min="0" step="0.01" value="<?php echo esc_attr((string) ($product['price'] ?? 0)); ?>" required>
|
||||
</label>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('库存', 'aksrt'); ?></span>
|
||||
<input type="number" name="stock" class="aksrt-product-editor__input" min="0" step="1" value="<?php echo esc_attr((string) ($product['stock'] ?? 0)); ?>" required>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('商品简介', 'aksrt'); ?></span>
|
||||
<textarea name="excerpt" class="aksrt-product-editor__textarea" rows="4"><?php echo esc_textarea((string) ($product['excerpt'] ?? '')); ?></textarea>
|
||||
</label>
|
||||
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('商品详情', 'aksrt'); ?></span>
|
||||
<textarea name="content" class="aksrt-product-editor__textarea" rows="10"><?php echo esc_textarea((string) ($product['content'] ?? '')); ?></textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('商品素材', 'aksrt'); ?></h2>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('主图 URL', 'aksrt'); ?></span>
|
||||
<input type="url" name="image" class="aksrt-product-editor__input" value="<?php echo esc_attr((string) ($product['image'] ?? '')); ?>" placeholder="https://">
|
||||
</label>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('图集 URL(每行一个)', 'aksrt'); ?></span>
|
||||
<textarea name="gallery" class="aksrt-product-editor__textarea" rows="5"><?php echo esc_textarea(implode("\n", (array) ($product['gallery'] ?? []))); ?></textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('规格选项', 'aksrt'); ?></h2>
|
||||
<p class="aksrt-product-editor__hint"><?php esc_html_e('每行一组:规格名|选项1:加价,选项2:加价。例如:颜色|红:0,蓝:10', 'aksrt'); ?></p>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('规格配置', 'aksrt'); ?></span>
|
||||
<textarea name="options_text" class="aksrt-product-editor__textarea" rows="6" data-aksrt-options-text placeholder="颜色|红:0,蓝:10 尺码|M:0,L:5"><?php
|
||||
$opt_lines = [];
|
||||
foreach ((array) ($product['options'] ?? []) as $group) {
|
||||
$vals = [];
|
||||
foreach ((array) ($group['values'] ?? []) as $v) {
|
||||
$vals[] = (string) ($v['label'] ?? '') . ':' . (string) ($v['price_change'] ?? 0);
|
||||
}
|
||||
if (!empty($group['name']) && $vals) {
|
||||
$opt_lines[] = (string) $group['name'] . '|' . implode(',', $vals);
|
||||
}
|
||||
}
|
||||
echo esc_textarea(implode("\n", $opt_lines));
|
||||
?></textarea>
|
||||
</label>
|
||||
<div class="aksrt-product-editor__columns">
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('起售价', 'aksrt'); ?></span>
|
||||
<input type="number" name="start_price" class="aksrt-product-editor__input" min="0" step="0.01" value="<?php echo esc_attr((string) ($product['start_price'] ?? 0)); ?>">
|
||||
</label>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('支付模式', 'aksrt'); ?></span>
|
||||
<select name="pay_modo" class="aksrt-product-editor__input">
|
||||
<option value="0" <?php selected((string) ($product['pay_modo'] ?? '0'), '0'); ?>><?php esc_html_e('现金', 'aksrt'); ?></option>
|
||||
<option value="points" <?php selected((string) ($product['pay_modo'] ?? '0'), 'points'); ?>><?php esc_html_e('积分', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('商品参数(每行 名称:值)', 'aksrt'); ?></span>
|
||||
<textarea name="product_params" class="aksrt-product-editor__textarea" rows="4"><?php echo esc_textarea((string) ($product['product_params'] ?? '')); ?></textarea>
|
||||
</label>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('视频地址(每行一个 URL)', 'aksrt'); ?></span>
|
||||
<textarea name="product_video" class="aksrt-product-editor__textarea" rows="3"><?php echo esc_textarea(implode("\n", (array) ($product['product_video'] ?? []))); ?></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('发货与售后', 'aksrt'); ?></h2>
|
||||
<div class="aksrt-product-editor__columns">
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('发货方式', 'aksrt'); ?></span>
|
||||
<select name="shipping_mode" class="aksrt-product-editor__input">
|
||||
<?php foreach ((array) ($edit_view['shipping_modes'] ?? []) as $mode) : ?>
|
||||
<option value="<?php echo esc_attr((string) ($mode['value'] ?? '')); ?>" <?php selected((string) ($product['shipping_mode'] ?? ''), (string) ($mode['value'] ?? '')); ?>>
|
||||
<?php echo esc_html((string) ($mode['label'] ?? '')); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('额外运费', 'aksrt'); ?></span>
|
||||
<input type="number" name="shipping_fee" class="aksrt-product-editor__input" min="0" step="0.01" value="<?php echo esc_attr((string) ($product['shipping_fee'] ?? 0)); ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('售后说明', 'aksrt'); ?></span>
|
||||
<textarea name="after_sale_policy" class="aksrt-product-editor__textarea" rows="4"><?php echo esc_textarea((string) ($product['after_sale_policy'] ?? '')); ?></textarea>
|
||||
</label>
|
||||
|
||||
<label class="aksrt-product-editor__checkbox">
|
||||
<input type="checkbox" name="support_refund" value="1" <?php checked(!empty($product['support_refund'])); ?>>
|
||||
<span><?php esc_html_e('支持退款/售后入口', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<aside class="aksrt-product-editor__sidebar">
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('发布设置', 'aksrt'); ?></h2>
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('状态', 'aksrt'); ?></span>
|
||||
<select name="status" class="aksrt-product-editor__input">
|
||||
<?php foreach ((array) ($edit_view['status_options'] ?? []) as $status_option) : ?>
|
||||
<option value="<?php echo esc_attr((string) ($status_option['value'] ?? 'draft')); ?>" <?php selected((string) ($product['status'] ?? 'draft'), (string) ($status_option['value'] ?? 'draft')); ?>>
|
||||
<?php echo esc_html((string) ($status_option['label'] ?? '')); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('分类(按住 Ctrl 可多选)', 'aksrt'); ?></span>
|
||||
<select name="categories[]" class="aksrt-product-editor__input" multiple size="6">
|
||||
<?php foreach ((array) (($edit_view['taxonomy']['categories'] ?? [])) as $category) : ?>
|
||||
<option value="<?php echo esc_attr((string) ($category['id'] ?? 0)); ?>" <?php echo in_array((int) ($category['id'] ?? 0), (array) ($product['categories'] ?? []), true) ? 'selected' : ''; ?>>
|
||||
<?php echo esc_html((string) ($category['name'] ?? '')); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="aksrt-product-editor__field">
|
||||
<span><?php esc_html_e('标签(英文逗号分隔)', 'aksrt'); ?></span>
|
||||
<input type="text" name="tags" class="aksrt-product-editor__input" value="<?php echo esc_attr(implode(', ', (array) ($product['tags'] ?? []))); ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-product-editor__panel">
|
||||
<h2><?php esc_html_e('动作', 'aksrt'); ?></h2>
|
||||
<div class="aksrt-product-editor__actions">
|
||||
<button type="submit" class="btn-primary btn-lg"><?php echo !empty($edit_view['is_edit']) ? esc_html__('保存修改', 'aksrt') : esc_html__('发布商品', 'aksrt'); ?></button>
|
||||
<a href="<?php echo esc_url(function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/')); ?>" class="btn-ghost btn-lg"><?php esc_html_e('返回中心', 'aksrt'); ?></a>
|
||||
</div>
|
||||
<p class="aksrt-product-editor__hint" data-aksrt-product-editor-message><?php esc_html_e('保存后会回到用户中心,商品信息供订单页和商品详情页复用。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</aside>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,471 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Product Detail
|
||||
* Template Post Type: page
|
||||
*
|
||||
* Enhanced: options selector, video gallery, params/services modal,
|
||||
* review tab, favorites, related products, mobile tabbar (§6.10).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$product_id = (int) ($_GET['product_id'] ?? 0);
|
||||
if ($product_id <= 0) {
|
||||
$product_id = (int) get_query_var('product_id', 0);
|
||||
}
|
||||
|
||||
$shop = class_exists('\AKSRT\Shop\Shop') ? \AKSRT\Shop\Shop::get_instance() : null;
|
||||
$product = function_exists('aksrt_get_product_page_view')
|
||||
? aksrt_get_product_page_view($product_id)
|
||||
: ($shop ? $shop->get_product_detail_view($product_id) : []);
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$is_fav = $shop && $user_id > 0 ? $shop->is_favorite($user_id, $product_id) : false;
|
||||
$options = $product['options'] ?? [];
|
||||
$has_options = !empty($options);
|
||||
$price_range = $product['price_range'] ?? [];
|
||||
$params = $product['params'] ?? [];
|
||||
$services = $product['services'] ?? [];
|
||||
$pay_modo = $product['pay_modo'] ?? '0';
|
||||
$scores = class_exists('\AKSRT\Shop\ProductReview') ? \AKSRT\Shop\ProductReview::get_instance()->get_product_scores($product_id) : [];
|
||||
$reviews = class_exists('\AKSRT\Shop\ProductReview') ? \AKSRT\Shop\ProductReview::get_instance()->get_reviews($product_id, ['per_page' => 5]) : ['items' => [], 'total' => 0];
|
||||
$author_id = (int) get_post_field('post_author', $product_id);
|
||||
$author = $author_id > 0 ? get_userdata($author_id) : null;
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--product" tabindex="-1">
|
||||
<?php if (is_active_sidebar('shop_product_top_fluid')) : ?>
|
||||
<div class="aksrt-fluid-widget aksrt-fluid-widget--shop"><?php dynamic_sidebar('shop_product_top_fluid'); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<?php if (!empty($product)) : ?>
|
||||
<div class="content-wrap container">
|
||||
<?php $has_shop_sidebar = is_active_sidebar('shop_product_sidebar'); ?>
|
||||
<div class="content-layout <?php echo $has_shop_sidebar ? 'content-layout--with-sidebar' : 'content-layout--no-sidebar'; ?>">
|
||||
<div class="content-layout__primary">
|
||||
<div
|
||||
class="aksrt-product-page"
|
||||
data-aksrt-product-page
|
||||
data-product-id="<?php echo esc_attr((string) $product_id); ?>"
|
||||
data-options='<?php echo esc_attr(wp_json_encode($options, JSON_UNESCAPED_UNICODE)); ?>'
|
||||
data-base-price="<?php echo esc_attr((string) (($product['start_price'] ?? 0) > 0 ? $product['start_price'] : ($product['price'] ?? 0))); ?>"
|
||||
data-base-stock="<?php echo esc_attr((string) ($product['stock'] ?? 0)); ?>"
|
||||
data-pay-modo="<?php echo esc_attr((string) $pay_modo); ?>"
|
||||
data-price-range="<?php echo !empty($price_range) && (($price_range['min'] ?? 0) !== ($price_range['max'] ?? 0)) ? '1' : '0'; ?>"
|
||||
>
|
||||
<div class="aksrt-product-page__layout">
|
||||
<!-- Gallery -->
|
||||
<section class="aksrt-product-page__gallery aksrt-product-page__panel">
|
||||
<?php if (!empty($product['image'])) : ?>
|
||||
<div class="aksrt-product-page__primary-image" data-aksrt-main-image>
|
||||
<img src="<?php echo esc_url((string) $product['image']); ?>" alt="<?php echo esc_attr((string) ($product['title'] ?? '')); ?>" id="product-main-img">
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-product-page__placeholder">
|
||||
<i class="fas fa-image" aria-hidden="true"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$gallery_items = (array) ($product['gallery'] ?? []);
|
||||
$cover_videos = (array) (get_post_meta($product_id, '_aksrt_cover_videos', true) ?: []);
|
||||
?>
|
||||
<?php if (!empty($gallery_items) || !empty($cover_videos)) : ?>
|
||||
<div class="aksrt-product-page__thumbs">
|
||||
<?php foreach ($cover_videos as $video_url) : ?>
|
||||
<button type="button" class="aksrt-product-page__thumb aksrt-product-page__thumb--video" data-aksrt-product-video="<?php echo esc_url($video_url); ?>">
|
||||
<i class="fas fa-play-circle"></i>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($gallery_items as $gallery_image) : ?>
|
||||
<button type="button" class="aksrt-product-page__thumb" data-aksrt-product-thumb="<?php echo esc_url($gallery_image); ?>">
|
||||
<img src="<?php echo esc_url($gallery_image); ?>" alt="">
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<!-- Summary -->
|
||||
<section class="aksrt-product-page__summary aksrt-product-page__panel">
|
||||
<div class="aksrt-product-page__badges">
|
||||
<?php if ($pay_modo === 'points') : ?>
|
||||
<span class="aksrt-product-page__badge aksrt-product-page__badge--points"><?php esc_html_e('积分商品', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($product['marketing']['headline'])) : ?>
|
||||
<span class="aksrt-product-page__badge aksrt-product-page__badge--promo"><?php echo esc_html((string) $product['marketing']['headline']); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($product['after_sale']['support_refund'])) : ?>
|
||||
<span class="aksrt-product-page__badge"><?php esc_html_e('支持售后', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<h1 class="aksrt-product-page__title"><?php echo esc_html((string) ($product['title'] ?? '')); ?></h1>
|
||||
|
||||
<!-- Price row with range support -->
|
||||
<div class="aksrt-product-page__price-row">
|
||||
<?php if ($has_options && !empty($price_range) && $price_range['min'] !== $price_range['max']) : ?>
|
||||
<strong class="aksrt-product-page__price" data-aksrt-dynamic-price>
|
||||
<?php echo $pay_modo === 'points' ? '' : '¥'; ?><?php echo esc_html(number_format($price_range['min'], 2)); ?> - <?php echo $pay_modo === 'points' ? '' : '¥'; ?><?php echo esc_html(number_format($price_range['max'], 2)); ?>
|
||||
<?php if ($pay_modo === 'points') : ?><small><?php esc_html_e('积分', 'aksrt'); ?></small><?php endif; ?>
|
||||
</strong>
|
||||
<?php else : ?>
|
||||
<strong class="aksrt-product-page__price" data-aksrt-dynamic-price>
|
||||
<?php echo $pay_modo === 'points' ? '' : '¥'; ?><?php echo esc_html(number_format((float) ($product['price'] ?? 0), 2)); ?>
|
||||
<?php if ($pay_modo === 'points') : ?><small><?php esc_html_e('积分', 'aksrt'); ?></small><?php endif; ?>
|
||||
</strong>
|
||||
<?php endif; ?>
|
||||
<span class="aksrt-product-page__sales"><?php printf(esc_html__('已售 %d', 'aksrt'), (int) ($product['sales'] ?? 0)); ?></span>
|
||||
<?php if (!empty($scores['average'])) : ?>
|
||||
<span class="aksrt-product-page__rating"><i class="fas fa-star"></i> <?php echo esc_html((string) $scores['average']); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($product['excerpt'])) : ?>
|
||||
<p class="aksrt-product-page__excerpt"><?php echo esc_html((string) $product['excerpt']); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-product-page__service-strip">
|
||||
<span><i class="fas fa-shield-alt"></i> <?php esc_html_e('主站统一交易保障', 'aksrt'); ?></span>
|
||||
<span><i class="fas fa-box-open"></i> <?php esc_html_e('与内容主线共用卡片与购买节奏', 'aksrt'); ?></span>
|
||||
</div>
|
||||
|
||||
<!-- Product options selector -->
|
||||
<?php if ($has_options) : ?>
|
||||
<div class="aksrt-product-page__options" data-aksrt-options-selector>
|
||||
<?php foreach ($options as $group_idx => $group) : ?>
|
||||
<div class="aksrt-product-page__option-group" data-group-index="<?php echo esc_attr((string) $group_idx); ?>">
|
||||
<span class="aksrt-product-page__option-label"><?php echo esc_html((string) ($group['name'] ?? '')); ?></span>
|
||||
<div class="aksrt-product-page__option-values aksrt-product-page__option-values--<?php echo esc_attr($group['view_mode'] ?? 'list'); ?>">
|
||||
<?php foreach ((array) ($group['values'] ?? []) as $val) : ?>
|
||||
<button type="button"
|
||||
class="aksrt-product-page__option-btn"
|
||||
data-option-group="<?php echo esc_attr((string) $group_idx); ?>"
|
||||
data-option-label="<?php echo esc_attr((string) ($val['label'] ?? '')); ?>"
|
||||
data-price-change="<?php echo esc_attr((string) ($val['price_change'] ?? 0)); ?>"
|
||||
<?php if (!empty($val['image'])) : ?>data-option-image="<?php echo esc_url($val['image']); ?>"<?php endif; ?>
|
||||
>
|
||||
<?php if (($group['view_mode'] ?? '') === 'img' && !empty($val['image'])) : ?>
|
||||
<img src="<?php echo esc_url($val['image']); ?>" alt="<?php echo esc_attr($val['label']); ?>">
|
||||
<?php endif; ?>
|
||||
<span><?php echo esc_html((string) ($val['label'] ?? '')); ?></span>
|
||||
<?php if ((float) ($val['price_change'] ?? 0) !== 0.0) : ?>
|
||||
<em><?php echo (float) $val['price_change'] > 0 ? '+' : ''; ?><?php echo esc_html(number_format((float) $val['price_change'], 2)); ?></em>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="aksrt-product-page__option-result" data-aksrt-option-result hidden>
|
||||
<span data-aksrt-selected-labels></span>
|
||||
<strong data-aksrt-resolved-price></strong>
|
||||
<span data-aksrt-resolved-stock></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Meta info -->
|
||||
<dl class="aksrt-product-page__meta">
|
||||
<div>
|
||||
<dt><?php esc_html_e('库存', 'aksrt'); ?></dt>
|
||||
<dd data-aksrt-stock-display><?php
|
||||
$stock_val = (int) ($product['stock'] ?? 0);
|
||||
echo $stock_val <= -1 ? esc_html__('充足', 'aksrt') : esc_html((string) $stock_val);
|
||||
?></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt><?php esc_html_e('配送', 'aksrt'); ?></dt>
|
||||
<dd><?php echo esc_html((string) (($product['shipping']['delivery_note'] ?? '') ?: __('标准配送', 'aksrt'))); ?></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt><?php esc_html_e('运费', 'aksrt'); ?></dt>
|
||||
<dd><?php
|
||||
$ship_fee = (float) ($product['shipping']['fee'] ?? 0);
|
||||
echo $ship_fee > 0 ? '¥' . esc_html(number_format($ship_fee, 2)) : esc_html__('包邮', 'aksrt');
|
||||
?></dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<!-- Params & Services quick links -->
|
||||
<?php if (!empty($params)) : ?>
|
||||
<button type="button" class="aksrt-product-page__info-trigger" data-aksrt-show-params>
|
||||
<i class="fas fa-list-ul"></i> <?php esc_html_e('商品参数', 'aksrt'); ?> <i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($services)) : ?>
|
||||
<button type="button" class="aksrt-product-page__info-trigger" data-aksrt-show-services>
|
||||
<i class="fas fa-shield-alt"></i> <?php esc_html_e('服务保障', 'aksrt'); ?> <i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Purchase box -->
|
||||
<div class="aksrt-product-page__purchase-box">
|
||||
<label class="aksrt-product-page__field">
|
||||
<span><?php esc_html_e('购买数量', 'aksrt'); ?></span>
|
||||
<div class="aksrt-product-page__quantity">
|
||||
<button type="button" class="aksrt-product-page__qty-btn" data-aksrt-qty-action="dec">-</button>
|
||||
<input type="number" min="1" max="<?php echo esc_attr((string) max(1, $stock_val > 0 ? $stock_val : 999)); ?>" value="1" class="aksrt-product-page__qty-input" data-aksrt-quantity>
|
||||
<button type="button" class="aksrt-product-page__qty-btn" data-aksrt-qty-action="inc">+</button>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<div class="aksrt-product-page__actions">
|
||||
<?php if (is_user_logged_in() && !empty($product['purchase_enabled'])) : ?>
|
||||
<button type="button" class="btn-outline btn-lg" data-aksrt-add-cart><?php esc_html_e('加入购物车', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-primary btn-lg" data-aksrt-buy-now>
|
||||
<?php echo $pay_modo === 'points' ? esc_html__('积分兑换', 'aksrt') : esc_html__('立即下单', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php elseif (!is_user_logged_in()) : ?>
|
||||
<a href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink())); ?>" class="btn-primary btn-lg">
|
||||
<?php esc_html_e('登录后购买', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn-primary btn-lg" disabled><?php esc_html_e('暂不可购买', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Auxiliary actions -->
|
||||
<div class="aksrt-product-page__aux-actions">
|
||||
<button type="button" class="aksrt-product-page__aux-btn<?php echo $is_fav ? ' is-active' : ''; ?>" data-aksrt-toggle-fav="<?php echo esc_attr((string) $product_id); ?>">
|
||||
<i class="<?php echo $is_fav ? 'fas' : 'far'; ?> fa-heart"></i>
|
||||
<?php esc_html_e('收藏', 'aksrt'); ?>
|
||||
</button>
|
||||
<button type="button" class="aksrt-product-page__aux-btn" data-aksrt-share>
|
||||
<i class="fas fa-share-alt"></i> <?php esc_html_e('分享', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Merchant info -->
|
||||
<?php if ($author) :
|
||||
$store_url = function_exists('aksrt_get_user_home_url')
|
||||
? add_query_arg('tab', 'product', aksrt_get_user_home_url($author_id))
|
||||
: get_author_posts_url($author_id);
|
||||
?>
|
||||
<div class="aksrt-product-page__merchant">
|
||||
<img src="<?php echo esc_url(function_exists('aksrt_get_avatar_url') ? aksrt_get_avatar_url($author_id) : get_avatar_url($author_id)); ?>" alt="" class="aksrt-product-page__merchant-avatar">
|
||||
<div>
|
||||
<strong><?php echo esc_html($author->display_name); ?></strong>
|
||||
<a href="<?php echo esc_url($store_url); ?>" class="aksrt-product-page__merchant-link"><?php esc_html_e('进入店铺', 'aksrt'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- Tabs: detail / reviews / custom -->
|
||||
<div class="aksrt-product-page__tabs">
|
||||
<nav class="aksrt-product-page__tab-nav">
|
||||
<button class="aksrt-product-page__tab-btn is-active" data-aksrt-tab="detail"><?php esc_html_e('商品详情', 'aksrt'); ?></button>
|
||||
<button class="aksrt-product-page__tab-btn" data-aksrt-tab="reviews">
|
||||
<?php esc_html_e('评价', 'aksrt'); ?>
|
||||
<?php if (($scores['total'] ?? 0) > 0) : ?>
|
||||
<em>(<?php echo esc_html((string) $scores['total']); ?>)</em>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="aksrt-product-page__tab-panel is-active" data-aksrt-tab-panel="detail">
|
||||
<div class="aksrt-product-page__content">
|
||||
<?php echo wp_kses_post((string) ($product['content'] ?? '')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-product-page__tab-panel" data-aksrt-tab-panel="reviews">
|
||||
<?php if (!empty($scores['total'])) : ?>
|
||||
<div class="aksrt-product-page__review-summary shop-comment-header" win-ajax-replace="shop-comment-header">
|
||||
<div class="comment-score">
|
||||
<strong class="aksrt-product-page__review-avg"><?php echo esc_html((string) ($scores['average'] ?? '0')); ?></strong>
|
||||
<span class="aksrt-product-page__review-level"><?php echo esc_html((string) ($scores['level'] ?? '')); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-product-page__review-counts comment-filter">
|
||||
<a href="javascript:;" class="comment-orderby c-theme badg" data-review-filter=""><?php esc_html_e('全部', 'aksrt'); ?></a>
|
||||
<a href="javascript:;" class="comment-orderby badg" data-review-filter="has_image"><?php printf(esc_html__('有图 %d', 'aksrt'), (int) ($scores['has_image'] ?? 0)); ?></a>
|
||||
<a href="javascript:;" class="comment-orderby badg" data-review-filter="good"><?php printf(esc_html__('好评 %d', 'aksrt'), (int) ($scores['good'] ?? 0)); ?></a>
|
||||
<a href="javascript:;" class="comment-orderby badg" data-review-filter="bad"><?php printf(esc_html__('中/差评 %d', 'aksrt'), (int) ($scores['bad'] ?? 0)); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-product-page__review-list shop-commentlist" data-aksrt-review-list data-product-id="<?php echo esc_attr((string) $product_id); ?>">
|
||||
<?php foreach (($reviews['items'] ?? []) as $review) : ?>
|
||||
<div class="aksrt-product-page__review-item comment" data-review-id="<?php echo esc_attr((string) ($review['id'] ?? '')); ?>">
|
||||
<div class="aksrt-product-page__review-header comment-header">
|
||||
<img src="<?php echo esc_url((string) ($review['user_avatar'] ?? '')); ?>" alt="" class="aksrt-product-page__review-avatar avatar-img comt-avatar">
|
||||
<span class="aksrt-product-page__review-name"><?php echo esc_html((string) ($review['user_name'] ?? '')); ?></span>
|
||||
<span class="aksrt-product-page__review-date"><?php echo esc_html((string) ($review['date'] ?? '')); ?></span>
|
||||
<span class="aksrt-product-page__review-stars comment-score-badge">
|
||||
<?php for ($s = 0; $s < 5; $s++) : ?>
|
||||
<i class="<?php echo $s < (int) round((float) ($review['rating_average'] ?? 0)) ? 'fas' : 'far'; ?> fa-star"></i>
|
||||
<?php endfor; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="aksrt-product-page__review-text comment-content">
|
||||
<?php
|
||||
$review_body = (string) ($review['content'] ?? '');
|
||||
if ($review_body === '') {
|
||||
echo esc_html__('用户未填写评价内容', 'aksrt');
|
||||
} elseif (function_exists('aksrt_render_comment_content')) {
|
||||
echo aksrt_render_comment_content($review_body); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
echo esc_html($review_body);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php if (!empty($review['images'])) : ?>
|
||||
<div class="aksrt-product-page__review-images comment-score-imgs imgbox-container">
|
||||
<?php foreach ((array) $review['images'] as $rimg) : ?>
|
||||
<img src="<?php echo esc_url($rimg); ?>" alt="" class="aksrt-product-page__review-img box-img">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($reviews['items'])) : ?>
|
||||
<p class="aksrt-product-page__review-empty"><?php esc_html_e('暂无评价', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Related products -->
|
||||
<?php
|
||||
$related_items = [];
|
||||
if ($shop && method_exists($shop, 'build_product_card_view')) {
|
||||
$related_q = new WP_Query([
|
||||
'post_type' => 'aksrt_product',
|
||||
'posts_per_page' => 6,
|
||||
'post_status' => 'publish',
|
||||
'post__not_in' => [$product_id],
|
||||
'ignore_sticky_posts' => true,
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'tax_query' => !empty($product['categories']) ? [[
|
||||
'taxonomy' => 'aksrt_product_cat',
|
||||
'field' => 'term_id',
|
||||
'terms' => wp_list_pluck($product['categories'], 'term_id'),
|
||||
]] : [],
|
||||
'orderby' => 'rand',
|
||||
]);
|
||||
while ($related_q->have_posts()) {
|
||||
$related_q->the_post();
|
||||
$card = $shop->build_product_card_view((int) get_the_ID());
|
||||
if (!empty($card['id'])) {
|
||||
$related_items[] = $card;
|
||||
}
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($related_items)) : ?>
|
||||
<section class="aksrt-product-page__related">
|
||||
<h2 class="aksrt-product-page__related-title"><?php esc_html_e('相关推荐', 'aksrt'); ?></h2>
|
||||
<div class="aksrt-product-archive__grid aksrt-product-archive__grid--default aksrt-product-page__related-grid">
|
||||
<?php foreach ($related_items as $related_product) :
|
||||
get_template_part('templates/parts/shop/product', 'card', [
|
||||
'product' => $related_product,
|
||||
'show_sales' => ((int) ($related_product['sales'] ?? 0) > 0),
|
||||
]);
|
||||
endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Params modal -->
|
||||
<?php if (!empty($params)) : ?>
|
||||
<div class="aksrt-modal" data-aksrt-params-modal hidden>
|
||||
<div class="aksrt-modal__overlay"></div>
|
||||
<div class="aksrt-modal__dialog">
|
||||
<div class="aksrt-modal__header">
|
||||
<h3><?php esc_html_e('商品参数', 'aksrt'); ?></h3>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-modal-close>×</button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body">
|
||||
<table class="aksrt-product-page__params-table">
|
||||
<?php foreach ($params as $param) : ?>
|
||||
<tr>
|
||||
<th><?php echo esc_html((string) ($param['name'] ?? '')); ?></th>
|
||||
<td><?php echo esc_html((string) ($param['value'] ?? '')); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Services modal -->
|
||||
<?php if (!empty($services)) : ?>
|
||||
<div class="aksrt-modal" data-aksrt-services-modal hidden>
|
||||
<div class="aksrt-modal__overlay"></div>
|
||||
<div class="aksrt-modal__dialog">
|
||||
<div class="aksrt-modal__header">
|
||||
<h3><?php esc_html_e('服务保障', 'aksrt'); ?></h3>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-modal-close>×</button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body">
|
||||
<?php foreach ($services as $service) : ?>
|
||||
<div class="aksrt-product-page__service-item">
|
||||
<?php if (!empty($service['icon'])) : ?>
|
||||
<img src="<?php echo esc_url($service['icon']); ?>" alt="" class="aksrt-product-page__service-icon">
|
||||
<?php else : ?>
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<strong><?php echo esc_html((string) ($service['name'] ?? '')); ?></strong>
|
||||
<?php if (!empty($service['desc'])) : ?>
|
||||
<p><?php echo esc_html((string) $service['desc']); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- .aksrt-product-page -->
|
||||
</div><!-- .content-layout__primary -->
|
||||
<?php if (!empty($has_shop_sidebar)) : ?>
|
||||
<aside class="content-layout__sidebar aksrt-shop-widget-zone">
|
||||
<?php dynamic_sidebar('shop_product_sidebar'); ?>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
</div><!-- .content-layout -->
|
||||
</div><!-- .content-wrap -->
|
||||
<?php if (is_active_sidebar('shop_product_bottom_fluid')) : ?>
|
||||
<div class="aksrt-fluid-widget aksrt-fluid-widget--shop"><?php dynamic_sidebar('shop_product_bottom_fluid'); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Mobile purchase tabbar -->
|
||||
<div class="aksrt-product-page__mobile-bar" data-aksrt-mobile-purchase>
|
||||
<button type="button" class="aksrt-product-page__mobile-btn" data-aksrt-toggle-fav="<?php echo esc_attr((string) $product_id); ?>">
|
||||
<i class="<?php echo $is_fav ? 'fas' : 'far'; ?> fa-heart"></i>
|
||||
</button>
|
||||
<button type="button" class="aksrt-product-page__mobile-btn" data-aksrt-add-cart>
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
</button>
|
||||
<button type="button" class="aksrt-product-page__mobile-buy btn-primary" data-aksrt-buy-now>
|
||||
<?php echo $pay_modo === 'points' ? esc_html__('积分兑换', 'aksrt') : esc_html__('立即购买', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-product-page container">
|
||||
<div class="aksrt-product-page__empty">
|
||||
<i class="fas fa-box-open" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e('商品不存在或已下架。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Shared product card (archive / related / storefront).
|
||||
*
|
||||
* Expected args:
|
||||
* - product: array from \AKSRT\Shop\Shop::build_product_card_view()
|
||||
* - show_sales: bool (optional)
|
||||
* - sales_cfg: array (optional; used when show_sales not provided)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$args = is_array($args ?? null) ? $args : [];
|
||||
$product = is_array($args['product'] ?? null) ? $args['product'] : [];
|
||||
if (empty($product) || empty($product['id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sales = (int) ($product['sales'] ?? 0);
|
||||
if (array_key_exists('show_sales', $args)) {
|
||||
$show_sales = !empty($args['show_sales']);
|
||||
} else {
|
||||
$sales_cfg = is_array($args['sales_cfg'] ?? null) ? $args['sales_cfg'] : [];
|
||||
$mode = (string) ($sales_cfg['show'] ?? 'show');
|
||||
$min_sales = max(0, (int) ($sales_cfg['show_min'] ?? 0));
|
||||
$show_sales = ($mode === 'show' && $sales > 0) || ($mode === 'threshold' && $sales >= $min_sales);
|
||||
}
|
||||
|
||||
$title = (string) ($product['title'] ?? '');
|
||||
$permalink = (string) ($product['permalink'] ?? '#');
|
||||
$image = (string) ($product['image'] ?? '');
|
||||
$excerpt = (string) ($product['excerpt'] ?? '');
|
||||
$price = (float) ($product['price'] ?? 0);
|
||||
?>
|
||||
<article class="aksrt-product-card product-item posts-item card ajax-item">
|
||||
<a href="<?php echo esc_url($permalink !== '' ? $permalink : '#'); ?>" class="aksrt-product-card__link">
|
||||
<?php if ($image !== '') : ?>
|
||||
<div class="aksrt-product-card__image">
|
||||
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr($title); ?>" loading="lazy">
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-product-card__image aksrt-product-card__image--placeholder"><i class="fas fa-image" aria-hidden="true"></i></div>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-product-card__body">
|
||||
<h3 class="aksrt-product-card__title"><?php echo esc_html($title); ?></h3>
|
||||
<?php if ($excerpt !== '') : ?>
|
||||
<p class="aksrt-product-card__excerpt"><?php echo esc_html(wp_trim_words($excerpt, 15)); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-product-card__footer">
|
||||
<span class="aksrt-product-card__price">¥<?php echo esc_html(number_format($price, 2)); ?></span>
|
||||
<?php if ($show_sales) : ?>
|
||||
<span class="aksrt-product-card__sales"><?php printf(esc_html__('已售 %d', 'aksrt'), $sales); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
@@ -1,149 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Product category hierarchical filter bar (zibll shop-cat-filter parity).
|
||||
*
|
||||
* Expects in scope:
|
||||
* - $filter array from Shop::build_product_cat_filter()
|
||||
* - $orderby string
|
||||
* - $order string ASC|DESC
|
||||
* - $term array|null
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$filter = is_array($filter ?? null) ? $filter : [];
|
||||
$orderby = sanitize_key((string) ($orderby ?? ($filter['orderby'] ?? 'date')));
|
||||
$order = strtoupper(sanitize_key((string) ($order ?? ($filter['order'] ?? 'DESC'))));
|
||||
if (!in_array($order, ['ASC', 'DESC'], true)) {
|
||||
$order = 'DESC';
|
||||
}
|
||||
$current_id = (int) ($filter['current_id'] ?? 0);
|
||||
$mode = (string) ($filter['mode'] ?? 'siblings');
|
||||
$siblings = is_array($filter['siblings'] ?? null) ? $filter['siblings'] : [];
|
||||
$children = is_array($filter['children'] ?? null) ? $filter['children'] : [];
|
||||
$child_tabs = is_array($filter['child_tabs'] ?? null) ? $filter['child_tabs'] : [];
|
||||
$parent_url = (string) ($filter['parent_url'] ?? '');
|
||||
$parent_id = (int) ($filter['parent_id'] ?? 0);
|
||||
$term_name = is_array($term ?? null) ? (string) ($term['name'] ?? '') : '';
|
||||
|
||||
$order_labels = [
|
||||
'date' => __('最新', 'aksrt'),
|
||||
'views' => __('最热', 'aksrt'),
|
||||
'favorite_count' => __('收藏', 'aksrt'),
|
||||
'score' => __('评分', 'aksrt'),
|
||||
'sales' => __('销量', 'aksrt'),
|
||||
];
|
||||
|
||||
$base_term_url = !empty($term['url']) ? (string) $term['url'] : '';
|
||||
if ($base_term_url === '' && $current_id > 0) {
|
||||
$link = get_term_link($current_id, 'aksrt_product_cat');
|
||||
$base_term_url = is_wp_error($link) ? '' : (string) $link;
|
||||
}
|
||||
|
||||
$blog = wp_strip_all_tags(get_bloginfo('name'));
|
||||
?>
|
||||
<div class="shop-cat-filter aksrt-shop-cat-filter zib-widget relative" data-aksrt-shop-cat-filter win-ajax-replace="shop-cat-filter">
|
||||
<?php if (!empty($siblings)) : ?>
|
||||
<div class="shop-cat-filter-tab list-inline scroll-x mini-scrollbar tab-nav-theme" data-aksrt-cat-tabs>
|
||||
<?php foreach ($siblings as $sib) :
|
||||
$sid = (int) ($sib['id'] ?? 0);
|
||||
$is_active = ($mode === 'with_children' && $sid === $current_id)
|
||||
|| ($mode === 'parent_siblings' && $sid === $parent_id)
|
||||
|| ($mode === 'siblings' && $sid === $current_id);
|
||||
?>
|
||||
<?php if ($is_active) : ?>
|
||||
<li class="active"><span class="focus-color"><?php echo esc_html((string) ($sib['name'] ?? '')); ?></span></li>
|
||||
<?php else : ?>
|
||||
<li>
|
||||
<a class="ajax-next"
|
||||
ajax-replace="true"
|
||||
route="1"
|
||||
route-title="<?php echo esc_attr((string) ($sib['name'] ?? '') . ' - ' . __('商城', 'aksrt') . ($blog ? ' · ' . $blog : '')); ?>"
|
||||
href="<?php echo esc_url((string) ($sib['url'] ?? '#')); ?>"
|
||||
data-aksrt-shop-term="<?php echo esc_attr((string) $sid); ?>">
|
||||
<?php echo esc_html((string) ($sib['name'] ?? '')); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($mode === 'with_children' && !empty($child_tabs)) : ?>
|
||||
<div class="shop-cat-filter-child" data-aksrt-cat-children>
|
||||
<span class="focus-color"><?php esc_html_e('全部', 'aksrt'); ?></span>
|
||||
<?php foreach ($child_tabs as $child) : ?>
|
||||
<a class="ajax-next"
|
||||
ajax-replace="true"
|
||||
route="1"
|
||||
route-title="<?php echo esc_attr((string) ($child['name'] ?? '') . ' - ' . __('商城', 'aksrt')); ?>"
|
||||
href="<?php echo esc_url((string) ($child['url'] ?? '#')); ?>"
|
||||
data-aksrt-shop-term="<?php echo esc_attr((string) ((int) ($child['id'] ?? 0))); ?>">
|
||||
<?php echo esc_html((string) ($child['name'] ?? '')); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($mode === 'parent_siblings' && !empty($children)) : ?>
|
||||
<div class="shop-cat-filter-child" data-aksrt-cat-children>
|
||||
<?php if ($parent_url !== '') : ?>
|
||||
<a class="ajax-next" ajax-replace="true" route="1" href="<?php echo esc_url($parent_url); ?>" data-aksrt-shop-term="<?php echo esc_attr((string) $parent_id); ?>">
|
||||
<?php esc_html_e('全部', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($children as $child) :
|
||||
$cid = (int) ($child['id'] ?? 0);
|
||||
?>
|
||||
<?php if ($cid === $current_id) : ?>
|
||||
<span class="focus-color"><?php echo esc_html((string) ($child['name'] ?? '')); ?></span>
|
||||
<?php else : ?>
|
||||
<a class="ajax-next"
|
||||
ajax-replace="true"
|
||||
route="1"
|
||||
route-title="<?php echo esc_attr((string) ($child['name'] ?? '') . ' - ' . __('商城', 'aksrt')); ?>"
|
||||
href="<?php echo esc_url((string) ($child['url'] ?? '#')); ?>"
|
||||
data-aksrt-shop-term="<?php echo esc_attr((string) $cid); ?>">
|
||||
<?php echo esc_html((string) ($child['name'] ?? '')); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="shop-cat-filter-orderby shop-cat-filter-child" win-ajax-replace="orderby" data-aksrt-shop-orderby-bar>
|
||||
<span class="opacity5"><?php esc_html_e('排序', 'aksrt'); ?></span>
|
||||
<?php foreach ($order_labels as $key => $label) :
|
||||
if ($orderby === $key) : ?>
|
||||
<span class="focus-color"><?php echo esc_html($label); ?></span>
|
||||
<?php else :
|
||||
$href = $base_term_url !== '' ? add_query_arg(['orderby' => $key], $base_term_url) : add_query_arg(['orderby' => $key]);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="<?php echo esc_attr($key); ?>">
|
||||
<?php echo esc_html($label); ?>
|
||||
</a>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
|
||||
// Price toggle (single 售价 control).
|
||||
if ($orderby === 'price') {
|
||||
$next_order = $order === 'DESC' ? 'ASC' : 'DESC';
|
||||
$icon = $next_order === 'DESC' ? 'up' : 'down';
|
||||
$href = $base_term_url !== ''
|
||||
? add_query_arg(['orderby' => 'price', 'order' => $next_order], $base_term_url)
|
||||
: add_query_arg(['orderby' => 'price', 'order' => $next_order]);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next focus-color" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="price" data-aksrt-shop-order="<?php echo esc_attr($next_order); ?>">
|
||||
<?php esc_html_e('售价', 'aksrt'); ?><i class="opacity5 ml3 fa fa-long-arrow-<?php echo esc_attr($icon); ?>"></i>
|
||||
</a>
|
||||
<?php } else {
|
||||
$href = $base_term_url !== ''
|
||||
? add_query_arg(['orderby' => 'price'], $base_term_url)
|
||||
: add_query_arg(['orderby' => 'price']);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="price">
|
||||
<?php esc_html_e('售价', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 商品分类归档模板 — zibll shop cat filter + ajax list 1:1 UX
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
if (is_active_sidebar('shop_home_top_fluid')) {
|
||||
echo '<div class="aksrt-fluid-widget aksrt-fluid-widget--shop">';
|
||||
dynamic_sidebar('shop_home_top_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$term = get_queried_object();
|
||||
$paged = max(1, (int) get_query_var('paged'));
|
||||
$orderby = '';
|
||||
$order = '';
|
||||
if (isset($_GET['orderby'])) {
|
||||
$orderby = sanitize_key(wp_unslash((string) $_GET['orderby']));
|
||||
} elseif (isset($_GET['shop_orderby'])) {
|
||||
$orderby = sanitize_key(wp_unslash((string) $_GET['shop_orderby']));
|
||||
}
|
||||
if (isset($_GET['order'])) {
|
||||
$order = sanitize_key(wp_unslash((string) $_GET['order']));
|
||||
}
|
||||
|
||||
$shop = class_exists('\AKSRT\Shop\Shop') ? \AKSRT\Shop\Shop::get_instance() : null;
|
||||
$view = $shop ? $shop->get_product_archive_view([
|
||||
'taxonomy' => 'aksrt_product_cat',
|
||||
'term_id' => $term ? (int) $term->term_id : 0,
|
||||
'paged' => $paged,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
]) : ['products' => [], 'term' => null, 'total' => 0, 'max_pages' => 0, 'orderby' => 'date', 'order' => 'DESC', 'paging' => 'number'];
|
||||
|
||||
$products = $view['products'] ?? [];
|
||||
$total = (int) ($view['total'] ?? 0);
|
||||
$max_pages = (int) ($view['max_pages'] ?? 0);
|
||||
$term_name = $term->name ?? '';
|
||||
$term_desc = $term->description ?? '';
|
||||
$active_orderby = (string) ($view['orderby'] ?? 'date');
|
||||
$active_order = strtoupper((string) ($view['order'] ?? 'DESC'));
|
||||
$paging = (string) ($view['paging'] ?? 'number');
|
||||
$ias_s = !empty($view['ias_s']);
|
||||
$ias_max = (int) ($view['ias_max'] ?? 5);
|
||||
$style = (string) ($view['style'] ?? 'default');
|
||||
$sales_cfg = is_array($view['sales'] ?? null) ? $view['sales'] : [];
|
||||
$filter = is_array($view['filter'] ?? null) ? $view['filter'] : null;
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div class="aksrt-product-archive container"
|
||||
data-aksrt-product-archive
|
||||
data-taxonomy="aksrt_product_cat"
|
||||
data-term-id="<?php echo esc_attr((string) ($term->term_id ?? 0)); ?>"
|
||||
data-orderby="<?php echo esc_attr($active_orderby); ?>"
|
||||
data-order="<?php echo esc_attr($active_order); ?>"
|
||||
data-page="<?php echo esc_attr((string) $paged); ?>"
|
||||
data-max-pages="<?php echo esc_attr((string) $max_pages); ?>"
|
||||
data-paging="<?php echo esc_attr($paging); ?>"
|
||||
data-ias="<?php echo $ias_s ? '1' : '0'; ?>"
|
||||
data-ias-max="<?php echo esc_attr((string) $ias_max); ?>"
|
||||
data-style="<?php echo esc_attr($style); ?>">
|
||||
|
||||
<header class="aksrt-product-archive__header shop-term-header ajax-item-header" data-aksrt-ajax-header>
|
||||
<div class="aksrt-product-archive__eyebrow"><?php esc_html_e('商城商品', 'aksrt'); ?></div>
|
||||
<h1 class="aksrt-product-archive__title" data-aksrt-archive-title><?php echo esc_html($term_name); ?></h1>
|
||||
<?php if ($term_desc) : ?>
|
||||
<p class="aksrt-product-archive__desc" data-aksrt-archive-desc><?php echo esc_html($term_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
<p class="aksrt-product-archive__count" data-aksrt-archive-count><?php printf(esc_html__('共 %d 件商品', 'aksrt'), $total); ?></p>
|
||||
|
||||
<?php
|
||||
if ($filter) {
|
||||
$orderby = $active_orderby;
|
||||
$order = $active_order;
|
||||
$term = $view['term'] ?? null;
|
||||
include get_template_directory() . '/templates/parts/shop/product-cat-filter.php';
|
||||
}
|
||||
?>
|
||||
</header>
|
||||
|
||||
<div class="ajaxpager product-lists-row aksrt-product-archive__ajaxpager"
|
||||
data-aksrt-ajaxpager
|
||||
data-aksrt-ajax-clear="1">
|
||||
<div class="post_ajax_loader" data-aksrt-ajax-loader data-aksrt-ajax-loader-hide hidden>
|
||||
<div class="aksrt-product-archive__skeleton">
|
||||
<?php for ($i = 0; $i < 4; $i++) : ?>
|
||||
<div class="aksrt-product-card aksrt-product-card--placeholder placeholder"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-product-archive__grid aksrt-product-archive__grid--<?php echo esc_attr($style); ?>" id="aksrt-product-grid" data-aksrt-product-grid>
|
||||
<?php if (!empty($products)) : ?>
|
||||
<?php foreach ($products as $product) :
|
||||
get_template_part('templates/parts/shop/product', 'card', [
|
||||
'product' => $product,
|
||||
'sales_cfg' => $sales_cfg,
|
||||
]);
|
||||
endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php echo function_exists('aksrt_get_ajax_null') ? aksrt_get_ajax_null(__('内容空空如也', 'aksrt')) : '<div class="aksrt-product-archive__empty ajax-item"><p>' . esc_html__('内容空空如也', 'aksrt') . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($max_pages > 1 && $paging === 'ajax') : ?>
|
||||
<div class="ajax-pag text-center theme-pagination">
|
||||
<div class="next-page ajax-next">
|
||||
<a href="#"
|
||||
class="ajax-next aksrt-load-more-btn"
|
||||
data-aksrt-shop-load-more
|
||||
data-aksrt-ajax-next><?php esc_html_e('加载更多', 'aksrt'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($max_pages > 1) : ?>
|
||||
<nav class="aksrt-product-archive__pagination" aria-label="<?php esc_attr_e('商品分页', 'aksrt'); ?>">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'total' => $max_pages,
|
||||
'current' => $paged,
|
||||
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
||||
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
||||
'add_args' => array_filter([
|
||||
'orderby' => $active_orderby,
|
||||
'order' => $active_orderby === 'price' ? $active_order : null,
|
||||
]),
|
||||
]);
|
||||
?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
wp_enqueue_script(
|
||||
'aksrt-product-archive',
|
||||
get_template_directory_uri() . '/assets/js/product-archive.js',
|
||||
['aksrt-script', 'aksrt-core-ajax-list'],
|
||||
AKSRT_VERSION,
|
||||
true
|
||||
);
|
||||
if (is_active_sidebar('shop_product_bottom_fluid')) {
|
||||
echo '<div class="aksrt-fluid-widget aksrt-fluid-widget--shop">';
|
||||
dynamic_sidebar('shop_product_bottom_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
get_footer();
|
||||
@@ -1,179 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 商品标签归档模板 — sort + ajax load-more (zibll tag parity)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
if (is_active_sidebar('shop_home_top_fluid')) {
|
||||
echo '<div class="aksrt-fluid-widget aksrt-fluid-widget--shop">';
|
||||
dynamic_sidebar('shop_home_top_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$term = get_queried_object();
|
||||
$paged = max(1, (int) get_query_var('paged'));
|
||||
$orderby = '';
|
||||
$order = '';
|
||||
if (isset($_GET['orderby'])) {
|
||||
$orderby = sanitize_key(wp_unslash((string) $_GET['orderby']));
|
||||
} elseif (isset($_GET['shop_orderby'])) {
|
||||
$orderby = sanitize_key(wp_unslash((string) $_GET['shop_orderby']));
|
||||
}
|
||||
if (isset($_GET['order'])) {
|
||||
$order = sanitize_key(wp_unslash((string) $_GET['order']));
|
||||
}
|
||||
|
||||
$shop = class_exists('\AKSRT\Shop\Shop') ? \AKSRT\Shop\Shop::get_instance() : null;
|
||||
$view = $shop ? $shop->get_product_archive_view([
|
||||
'taxonomy' => 'aksrt_product_tag',
|
||||
'term_id' => $term ? (int) $term->term_id : 0,
|
||||
'paged' => $paged,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
]) : ['products' => [], 'term' => null, 'total' => 0, 'max_pages' => 0, 'orderby' => 'date', 'order' => 'DESC', 'paging' => 'number'];
|
||||
|
||||
$products = $view['products'] ?? [];
|
||||
$total = (int) ($view['total'] ?? 0);
|
||||
$max_pages = (int) ($view['max_pages'] ?? 0);
|
||||
$term_name = $term->name ?? '';
|
||||
$term_desc = $term->description ?? '';
|
||||
$active_orderby = (string) ($view['orderby'] ?? 'date');
|
||||
$active_order = strtoupper((string) ($view['order'] ?? 'DESC'));
|
||||
$paging = (string) ($view['paging'] ?? 'number');
|
||||
$ias_s = !empty($view['ias_s']);
|
||||
$ias_max = (int) ($view['ias_max'] ?? 5);
|
||||
$style = (string) ($view['style'] ?? 'default');
|
||||
$sales_cfg = is_array($view['sales'] ?? null) ? $view['sales'] : [];
|
||||
|
||||
$order_labels = [
|
||||
'date' => __('最新', 'aksrt'),
|
||||
'views' => __('最热', 'aksrt'),
|
||||
'favorite_count' => __('收藏', 'aksrt'),
|
||||
'score' => __('评分', 'aksrt'),
|
||||
'sales' => __('销量', 'aksrt'),
|
||||
];
|
||||
$base_url = $term && !is_wp_error(get_term_link($term)) ? get_term_link($term) : '';
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div class="aksrt-product-archive container"
|
||||
data-aksrt-product-archive
|
||||
data-taxonomy="aksrt_product_tag"
|
||||
data-term-id="<?php echo esc_attr((string) ($term->term_id ?? 0)); ?>"
|
||||
data-orderby="<?php echo esc_attr($active_orderby); ?>"
|
||||
data-order="<?php echo esc_attr($active_order); ?>"
|
||||
data-page="<?php echo esc_attr((string) $paged); ?>"
|
||||
data-max-pages="<?php echo esc_attr((string) $max_pages); ?>"
|
||||
data-paging="<?php echo esc_attr($paging); ?>"
|
||||
data-ias="<?php echo $ias_s ? '1' : '0'; ?>"
|
||||
data-ias-max="<?php echo esc_attr((string) $ias_max); ?>"
|
||||
data-style="<?php echo esc_attr($style); ?>">
|
||||
|
||||
<header class="aksrt-product-archive__header shop-term-header" data-aksrt-ajax-header>
|
||||
<div class="aksrt-product-archive__eyebrow"><?php esc_html_e('商城标签', 'aksrt'); ?></div>
|
||||
<h1 class="aksrt-product-archive__title"><?php echo esc_html($term_name); ?></h1>
|
||||
<?php if ($term_desc) : ?>
|
||||
<p class="aksrt-product-archive__desc"><?php echo esc_html($term_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
<p class="aksrt-product-archive__count" data-aksrt-archive-count><?php printf(esc_html__('共 %d 件商品', 'aksrt'), $total); ?></p>
|
||||
|
||||
<div class="shop-cat-filter-orderby shop-cat-filter-child" win-ajax-replace="orderby" data-aksrt-shop-orderby-bar>
|
||||
<span class="opacity5"><?php esc_html_e('排序', 'aksrt'); ?></span>
|
||||
<?php foreach ($order_labels as $key => $label) :
|
||||
if ($active_orderby === $key) : ?>
|
||||
<span class="focus-color"><?php echo esc_html($label); ?></span>
|
||||
<?php else :
|
||||
$href = $base_url ? add_query_arg(['orderby' => $key], $base_url) : add_query_arg(['orderby' => $key]);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="<?php echo esc_attr($key); ?>">
|
||||
<?php echo esc_html($label); ?>
|
||||
</a>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
if ($active_orderby === 'price') {
|
||||
$next_order = $active_order === 'DESC' ? 'ASC' : 'DESC';
|
||||
$icon = $next_order === 'DESC' ? 'up' : 'down';
|
||||
$href = $base_url ? add_query_arg(['orderby' => 'price', 'order' => $next_order], $base_url) : add_query_arg(['orderby' => 'price', 'order' => $next_order]);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next focus-color" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="price" data-aksrt-shop-order="<?php echo esc_attr($next_order); ?>">
|
||||
<?php esc_html_e('售价', 'aksrt'); ?><i class="opacity5 ml3 fa fa-long-arrow-<?php echo esc_attr($icon); ?>"></i>
|
||||
</a>
|
||||
<?php } else {
|
||||
$href = $base_url ? add_query_arg(['orderby' => 'price'], $base_url) : add_query_arg(['orderby' => 'price']);
|
||||
?>
|
||||
<a rel="nofollow" ajax-replace="true" class="ajax-next" href="<?php echo esc_url($href); ?>" data-aksrt-shop-orderby="price">
|
||||
<?php esc_html_e('售价', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="ajaxpager product-lists-row aksrt-product-archive__ajaxpager" data-aksrt-ajaxpager data-aksrt-ajax-clear="1">
|
||||
<div class="post_ajax_loader" data-aksrt-ajax-loader data-aksrt-ajax-loader-hide hidden>
|
||||
<div class="aksrt-product-archive__skeleton">
|
||||
<?php for ($i = 0; $i < 4; $i++) : ?>
|
||||
<div class="aksrt-product-card aksrt-product-card--placeholder placeholder"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-product-archive__grid aksrt-product-archive__grid--<?php echo esc_attr($style); ?>" id="aksrt-product-grid" data-aksrt-product-grid>
|
||||
<?php if (!empty($products)) : ?>
|
||||
<?php foreach ($products as $product) :
|
||||
get_template_part('templates/parts/shop/product', 'card', [
|
||||
'product' => $product,
|
||||
'sales_cfg' => $sales_cfg,
|
||||
]);
|
||||
endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php echo function_exists('aksrt_get_ajax_null') ? aksrt_get_ajax_null(__('内容空空如也', 'aksrt')) : '<div class="aksrt-product-archive__empty ajax-item"><p>' . esc_html__('内容空空如也', 'aksrt') . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($max_pages > 1 && $paging === 'ajax') : ?>
|
||||
<div class="ajax-pag text-center theme-pagination">
|
||||
<div class="next-page ajax-next">
|
||||
<a href="#" class="ajax-next aksrt-load-more-btn" data-aksrt-shop-load-more data-aksrt-ajax-next><?php esc_html_e('加载更多', 'aksrt'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($max_pages > 1) : ?>
|
||||
<nav class="aksrt-product-archive__pagination" aria-label="<?php esc_attr_e('商品分页', 'aksrt'); ?>">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'total' => $max_pages,
|
||||
'current' => $paged,
|
||||
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
||||
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
||||
'add_args' => array_filter([
|
||||
'orderby' => $active_orderby,
|
||||
'order' => $active_orderby === 'price' ? $active_order : null,
|
||||
]),
|
||||
]);
|
||||
?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
wp_enqueue_script(
|
||||
'aksrt-product-archive',
|
||||
get_template_directory_uri() . '/assets/js/product-archive.js',
|
||||
['aksrt-script', 'aksrt-core-ajax-list'],
|
||||
AKSRT_VERSION,
|
||||
true
|
||||
);
|
||||
if (is_active_sidebar('shop_product_bottom_fluid')) {
|
||||
echo '<div class="aksrt-fluid-widget aksrt-fluid-widget--shop">';
|
||||
dynamic_sidebar('shop_product_bottom_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
get_footer();
|
||||
Reference in new issue
Block a user