Merge pull request 'feat(admin): expand native product commerce meta fields' (#151) from worktree-zibll-native-admin-menus into main
Reviewed-on: CYL/wordpress-theme-aksrt#151
This commit is contained in:
@@ -99,8 +99,8 @@ Note: zibll「商品管理」`zibpay_product_page` is **paid article sales**, no
|
||||
| 2b Shipping/after-sale/coupons/income/rebate | done |
|
||||
| 3 users.php submenus | done |
|
||||
| 4 SPA strip | done (ops routes redirect to native) |
|
||||
| 5+ behavior parity | in progress — shipping list create + pending-to-ship board; after-sale filters/actions; order note/quick actions; coupons field parity + batch/enable; charge-cards expires + code dump + search/labels |
|
||||
| 5 remaining | product/forum runtime field parity; express timeline; coupon product_scope UI |
|
||||
| 5+ behavior parity | in progress — shipping list create + pending-to-ship board; after-sale filters/actions; order note/quick actions; coupons field parity + batch/enable; charge-cards expires + code dump + search/labels; product meta shipping/service/limit fields |
|
||||
| 5 remaining | forum runtime field parity; express timeline; coupon product_scope UI |
|
||||
|
||||
## Dual-UI rule
|
||||
|
||||
|
||||
@@ -47,14 +47,24 @@ class AKSRT_Product_Meta_Box {
|
||||
$gallery = is_array($gallery) ? $gallery : [];
|
||||
$shipping_mode = (string) get_post_meta($post->ID, '_aksrt_shipping_mode', true);
|
||||
$shipping_fee = (float) get_post_meta($post->ID, '_aksrt_shipping_fee', true);
|
||||
$shipping_fee_type = (string) (get_post_meta($post->ID, '_aksrt_shipping_fee_type', true) ?: 'fixed');
|
||||
$shipping_fee_free = (float) get_post_meta($post->ID, '_aksrt_shipping_fee_free_amount', true);
|
||||
$shipping_delivery = (string) get_post_meta($post->ID, '_aksrt_shipping_delivery_desc', true);
|
||||
$shipping_tip = (string) get_post_meta($post->ID, '_aksrt_shipping_tip', true);
|
||||
$after_sale_policy = (string) get_post_meta($post->ID, '_aksrt_after_sale_policy', true);
|
||||
$support_refund = get_post_meta($post->ID, '_aksrt_support_refund', true);
|
||||
$support_refund = $support_refund === '' ? '1' : (string) $support_refund;
|
||||
$service = (string) get_post_meta($post->ID, '_aksrt_service', true);
|
||||
$service_tip = (string) get_post_meta($post->ID, '_aksrt_service_tip', true);
|
||||
$limit_buy = get_post_meta($post->ID, '_aksrt_limit_buy', true);
|
||||
$limit_buy = $limit_buy === '' ? -1 : (int) $limit_buy;
|
||||
$limit_buy_note = (string) get_post_meta($post->ID, '_aksrt_limit_buy_note', true);
|
||||
$stock_type = (string) (get_post_meta($post->ID, '_aksrt_stock_type', true) ?: 'all');
|
||||
$pay_modo = (string) (get_post_meta($post->ID, '_aksrt_pay_modo', true) ?: '0');
|
||||
$start_price = (float) get_post_meta($post->ID, '_aksrt_start_price', true);
|
||||
$product_rebate = (string) get_post_meta($post->ID, '_aksrt_product_rebate', true);
|
||||
$product_params = (string) get_post_meta($post->ID, '_aksrt_product_params', true);
|
||||
$user_required = (string) get_post_meta($post->ID, '_aksrt_user_required', true);
|
||||
$delivery_note = (string) get_post_meta($post->ID, '_aksrt_delivery_note', true);
|
||||
$marketing = (string) get_post_meta($post->ID, '_aksrt_marketing_headline', true);
|
||||
|
||||
@@ -69,6 +79,11 @@ class AKSRT_Product_Meta_Box {
|
||||
'all' => __('统一库存', 'aksrt'),
|
||||
'opts' => __('按选项/变体', 'aksrt'),
|
||||
];
|
||||
$fee_types = [
|
||||
'free' => __('包邮', 'aksrt'),
|
||||
'fixed' => __('固定运费', 'aksrt'),
|
||||
'amount_free' => __('满额包邮', 'aksrt'),
|
||||
];
|
||||
?>
|
||||
<style>
|
||||
.aksrt-pmb-product .row { display:grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0 0 12px; align-items:start; }
|
||||
@@ -123,6 +138,17 @@ class AKSRT_Product_Meta_Box {
|
||||
<p class="hint"><?php esc_html_e('-1 不限购。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_limit_buy_note"><?php esc_html_e('限购说明', 'aksrt'); ?></label>
|
||||
<input type="text" id="aksrt_limit_buy_note" name="aksrt_limit_buy_note" value="<?php echo esc_attr($limit_buy_note); ?>">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_product_rebate"><?php esc_html_e('推广返佣', 'aksrt'); ?></label>
|
||||
<div>
|
||||
<input type="text" id="aksrt_product_rebate" name="aksrt_product_rebate" value="<?php echo esc_attr($product_rebate); ?>" placeholder="<?php esc_attr_e('如 10 或 10%', 'aksrt'); ?>">
|
||||
<p class="hint"><?php esc_html_e('可填固定金额或百分比,具体解析由返佣服务处理。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4><?php esc_html_e('素材', 'aksrt'); ?></h4>
|
||||
<div class="row">
|
||||
@@ -138,6 +164,12 @@ class AKSRT_Product_Meta_Box {
|
||||
<textarea id="aksrt_product_gallery" name="aksrt_product_gallery" rows="4" placeholder="<?php esc_attr_e('每行一个图片 URL', 'aksrt'); ?>"><?php echo esc_textarea(implode("\n", $gallery)); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_product_params"><?php esc_html_e('商品参数', 'aksrt'); ?></label>
|
||||
<div>
|
||||
<textarea id="aksrt_product_params" name="aksrt_product_params" rows="4" placeholder="<?php esc_attr_e('每行一条参数,如 品牌:AKSRT', 'aksrt'); ?>"><?php echo esc_textarea($product_params); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4><?php esc_html_e('发货与售后', 'aksrt'); ?></h4>
|
||||
<div class="grid-2">
|
||||
@@ -150,9 +182,31 @@ class AKSRT_Product_Meta_Box {
|
||||
</select>
|
||||
</div>
|
||||
<div class="row" style="grid-template-columns:1fr;">
|
||||
<label for="aksrt_shipping_fee"><?php esc_html_e('额外运费(元)', 'aksrt'); ?></label>
|
||||
<label for="aksrt_shipping_fee_type"><?php esc_html_e('运费类型', 'aksrt'); ?></label>
|
||||
<select id="aksrt_shipping_fee_type" name="aksrt_shipping_fee_type">
|
||||
<?php foreach ($fee_types as $key => $label) : ?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php selected($shipping_fee_type, $key); ?>><?php echo esc_html($label); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-2">
|
||||
<div class="row" style="grid-template-columns:1fr;">
|
||||
<label for="aksrt_shipping_fee"><?php esc_html_e('运费金额(元)', 'aksrt'); ?></label>
|
||||
<input type="number" id="aksrt_shipping_fee" name="aksrt_shipping_fee" min="0" step="0.01" value="<?php echo esc_attr((string) $shipping_fee); ?>">
|
||||
</div>
|
||||
<div class="row" style="grid-template-columns:1fr;">
|
||||
<label for="aksrt_shipping_fee_free_amount"><?php esc_html_e('满额包邮门槛', 'aksrt'); ?></label>
|
||||
<input type="number" id="aksrt_shipping_fee_free_amount" name="aksrt_shipping_fee_free_amount" min="0" step="0.01" value="<?php echo esc_attr((string) $shipping_fee_free); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_shipping_delivery_desc"><?php esc_html_e('发货时效说明', 'aksrt'); ?></label>
|
||||
<input type="text" id="aksrt_shipping_delivery_desc" name="aksrt_shipping_delivery_desc" value="<?php echo esc_attr($shipping_delivery); ?>" placeholder="<?php esc_attr_e('如 付款后 24 小时内发货', 'aksrt'); ?>">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_shipping_tip"><?php esc_html_e('物流提示', 'aksrt'); ?></label>
|
||||
<input type="text" id="aksrt_shipping_tip" name="aksrt_shipping_tip" value="<?php echo esc_attr($shipping_tip); ?>">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_after_sale_policy"><?php esc_html_e('售后说明', 'aksrt'); ?></label>
|
||||
@@ -167,6 +221,18 @@ class AKSRT_Product_Meta_Box {
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_service"><?php esc_html_e('服务承诺', 'aksrt'); ?></label>
|
||||
<textarea id="aksrt_service" name="aksrt_service" rows="3" placeholder="<?php esc_attr_e('每行一条服务承诺', 'aksrt'); ?>"><?php echo esc_textarea($service); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_service_tip"><?php esc_html_e('服务提示', 'aksrt'); ?></label>
|
||||
<input type="text" id="aksrt_service_tip" name="aksrt_service_tip" value="<?php echo esc_attr($service_tip); ?>">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_user_required"><?php esc_html_e('下单需填信息', 'aksrt'); ?></label>
|
||||
<textarea id="aksrt_user_required" name="aksrt_user_required" rows="3" placeholder="<?php esc_attr_e('每行一项,如 QQ / 游戏角色名', 'aksrt'); ?>"><?php echo esc_textarea($user_required); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="aksrt_delivery_note"><?php esc_html_e('发货备注', 'aksrt'); ?></label>
|
||||
<input type="text" id="aksrt_delivery_note" name="aksrt_delivery_note" value="<?php echo esc_attr($delivery_note); ?>">
|
||||
@@ -176,7 +242,7 @@ class AKSRT_Product_Meta_Box {
|
||||
<input type="text" id="aksrt_marketing_headline" name="aksrt_marketing_headline" value="<?php echo esc_attr($marketing); ?>">
|
||||
</div>
|
||||
<p class="hint">
|
||||
<?php esc_html_e('SKU 变体可在后续版本通过变体表管理;当前列表列已显示价格/库存/销量。', 'aksrt'); ?>
|
||||
<?php esc_html_e('SKU 变体请使用下方「商品变体」面板;列表列已显示价格/库存/销量。', 'aksrt'); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
@@ -213,9 +279,19 @@ class AKSRT_Product_Meta_Box {
|
||||
|
||||
$shipping_mode = isset($_POST['aksrt_shipping_mode']) ? sanitize_key((string) wp_unslash($_POST['aksrt_shipping_mode'])) : '';
|
||||
$shipping_fee = isset($_POST['aksrt_shipping_fee']) ? max(0, (float) wp_unslash($_POST['aksrt_shipping_fee'])) : 0;
|
||||
$shipping_fee_type = isset($_POST['aksrt_shipping_fee_type']) ? sanitize_key((string) wp_unslash($_POST['aksrt_shipping_fee_type'])) : 'fixed';
|
||||
if (!in_array($shipping_fee_type, ['free', 'fixed', 'amount_free'], true)) {
|
||||
$shipping_fee_type = 'fixed';
|
||||
}
|
||||
$shipping_fee_free = isset($_POST['aksrt_shipping_fee_free_amount']) ? max(0, (float) wp_unslash($_POST['aksrt_shipping_fee_free_amount'])) : 0;
|
||||
$shipping_delivery = isset($_POST['aksrt_shipping_delivery_desc']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_shipping_delivery_desc'])) : '';
|
||||
$shipping_tip = isset($_POST['aksrt_shipping_tip']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_shipping_tip'])) : '';
|
||||
$policy = isset($_POST['aksrt_after_sale_policy']) ? sanitize_textarea_field((string) wp_unslash($_POST['aksrt_after_sale_policy'])) : '';
|
||||
$support_refund = !empty($_POST['aksrt_support_refund']) ? '1' : '0';
|
||||
$service = isset($_POST['aksrt_service']) ? sanitize_textarea_field((string) wp_unslash($_POST['aksrt_service'])) : '';
|
||||
$service_tip = isset($_POST['aksrt_service_tip']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_service_tip'])) : '';
|
||||
$limit_buy = isset($_POST['aksrt_limit_buy']) ? max(-1, min(9999, (int) wp_unslash($_POST['aksrt_limit_buy']))) : -1;
|
||||
$limit_buy_note = isset($_POST['aksrt_limit_buy_note']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_limit_buy_note'])) : '';
|
||||
$stock_type = isset($_POST['aksrt_stock_type']) ? sanitize_key((string) wp_unslash($_POST['aksrt_stock_type'])) : 'all';
|
||||
if (!in_array($stock_type, ['all', 'opts'], true)) {
|
||||
$stock_type = 'all';
|
||||
@@ -225,6 +301,9 @@ class AKSRT_Product_Meta_Box {
|
||||
$pay_modo = '0';
|
||||
}
|
||||
$start_price = isset($_POST['aksrt_start_price']) ? max(0, (float) wp_unslash($_POST['aksrt_start_price'])) : 0;
|
||||
$product_rebate = isset($_POST['aksrt_product_rebate']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_product_rebate'])) : '';
|
||||
$product_params = isset($_POST['aksrt_product_params']) ? sanitize_textarea_field((string) wp_unslash($_POST['aksrt_product_params'])) : '';
|
||||
$user_required = isset($_POST['aksrt_user_required']) ? sanitize_textarea_field((string) wp_unslash($_POST['aksrt_user_required'])) : '';
|
||||
$delivery_note = isset($_POST['aksrt_delivery_note']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_delivery_note'])) : '';
|
||||
$marketing = isset($_POST['aksrt_marketing_headline']) ? sanitize_text_field((string) wp_unslash($_POST['aksrt_marketing_headline'])) : '';
|
||||
|
||||
@@ -235,12 +314,22 @@ class AKSRT_Product_Meta_Box {
|
||||
update_post_meta($post_id, '_aksrt_shipping_mode', $shipping_mode);
|
||||
update_post_meta($post_id, '_aksrt_shipping_type', $shipping_mode);
|
||||
update_post_meta($post_id, '_aksrt_shipping_fee', $shipping_fee);
|
||||
update_post_meta($post_id, '_aksrt_shipping_fee_type', $shipping_fee_type);
|
||||
update_post_meta($post_id, '_aksrt_shipping_fee_free_amount', $shipping_fee_free);
|
||||
update_post_meta($post_id, '_aksrt_shipping_delivery_desc', $shipping_delivery);
|
||||
update_post_meta($post_id, '_aksrt_shipping_tip', $shipping_tip);
|
||||
update_post_meta($post_id, '_aksrt_after_sale_policy', $policy);
|
||||
update_post_meta($post_id, '_aksrt_support_refund', $support_refund);
|
||||
update_post_meta($post_id, '_aksrt_service', $service);
|
||||
update_post_meta($post_id, '_aksrt_service_tip', $service_tip);
|
||||
update_post_meta($post_id, '_aksrt_limit_buy', $limit_buy);
|
||||
update_post_meta($post_id, '_aksrt_limit_buy_note', $limit_buy_note);
|
||||
update_post_meta($post_id, '_aksrt_stock_type', $stock_type);
|
||||
update_post_meta($post_id, '_aksrt_pay_modo', $pay_modo);
|
||||
update_post_meta($post_id, '_aksrt_start_price', $start_price);
|
||||
update_post_meta($post_id, '_aksrt_product_rebate', $product_rebate);
|
||||
update_post_meta($post_id, '_aksrt_product_params', $product_params);
|
||||
update_post_meta($post_id, '_aksrt_user_required', $user_required);
|
||||
update_post_meta($post_id, '_aksrt_delivery_note', $delivery_note);
|
||||
update_post_meta($post_id, '_aksrt_marketing_headline', $marketing);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user