导入 AKSRT 主题开发源码
This commit is contained in:
1 parent
9681dd3d48
commit
1268a55dd0
595 files changed
+127705
No files matched your search
@@ -0,0 +1,281 @@
|
||||
<?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 (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'; ?>"
|
||||
>
|
||||
<div class="aksrt-cart-page__header">
|
||||
<div>
|
||||
<h1 class="aksrt-cart-page__title"><?php esc_html_e('购物车', 'aksrt'); ?></h1>
|
||||
<p class="aksrt-cart-page__subtitle"><?php esc_html_e('在下单前确认地址、运费、优惠券和支付方式。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?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 get_footer(); ?>
|
||||
Reference in new issue
Block a user