From bb12f2cd33ed4404b7dd3261ab6db058475ebc01 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Fri, 7 Nov 2025 16:00:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E5=A2=9E=E5=BC=BA=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=8D=86=E7=BB=91=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8C=89=E5=88=86=E7=B1=BB=E6=88=96=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增选择模式(包含/排除/全部)配置 - 支持按产品分类或标签进行前端分组显示 - 优化后台界面布局和交互体验 - 添加动态加载术语功能 - 完善前端样式和兼容性 --- assets/css/admin.css | 21 ++- assets/js/admin.js | 127 +++++++++++------- .../class-yoone-product-bundles-admin.php | 127 +++++++++++++++--- includes/class-yoone-product-bundles.php | 47 ++++++- templates/global/yoone-bundle-form.php | 47 ++++++- 5 files changed, 291 insertions(+), 78 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 9711c72..02915c6 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -1,3 +1,18 @@ -/* Yoone Product Bundles 后台样式(简版) */ -#yoone_bundle_data .description { color: #666; display: block; margin-top: 6px; } -#yoone_bundle_data .form-field { margin-bottom: 12px; } \ No newline at end of file +/* Yoone Product Bundles 后台样式优化 */ +#yoone_bundle_data { padding-top: 8px; } +#yoone_bundle_data .form-field { margin-bottom: 16px; } +/* 让标签独占一行,避免窄屏换行难看 */ +#yoone_bundle_data .form-field > label { display: block; font-weight: 600; margin-bottom: 6px; } +/* 描述放到下一行,颜色更柔和 */ +#yoone_bundle_data .description { color: #666; display: block; margin-top: 6px; line-height: 1.4; } +/* 选择器与搜索框占满一行 */ +#yoone_bundle_data .wc-product-search, +#yoone_bundle_data .wc-enhanced-select, +#yoone_bundle_data select, +#yoone_bundle_data input[type="text"], +#yoone_bundle_data input[type="number"] { width: 100% !important; max-width: 820px; } +/* Select2 容器也撑满 */ +#yoone_bundle_data .select2-container { width: 100% !important; max-width: 820px; } +/* 按钮的间距 */ +#yoone_bundle_data .yoone-add-all-simple-products { margin-left: 0; margin-bottom: 8px; } +#yoone_bundle_data .yoone-clear-products-list { margin-left: 8px; margin-bottom: 8px; } \ No newline at end of file diff --git a/assets/js/admin.js b/assets/js/admin.js index 2563f26..5dd185d 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -1,52 +1,85 @@ -(function($) { - $(document).ready(function() { - // “一键添加所有 Simple Product” 按钮点击事件 - $(document).on('click', '.yoone-add-all-simple-products', function(e) { - e.preventDefault(); +/* Yoone Product Bundles - Admin dynamic grouping terms + * When switching grouping taxonomy (category/tag), refresh the terms select list accordingly. + */ +(function($){ + $(function(){ + var $tax = $('#yoone_bundle_group_taxonomy'); + var $terms = $('#yoone_bundle_group_terms'); + var $addAllBtn = $('.yoone-add-all-simple-products'); + var $clearBtn = $('.yoone-clear-products-list'); + var $productSelect = $('select[name="yoone_bundle_allowed_products[]"]'); - var $button = $(this); - var $select = $('select.wc-product-search[name="yoone_bundle_allowed_products[]"]'); - var nonce = $('#yoone_bundle_admin_nonce_field').val(); + if (typeof YoonePBAdmin === 'undefined') { + return; + } - $button.prop('disabled', true).text('正在加载...'); + function refreshTerms(tax) { + if (!tax) return; + $terms.prop('disabled', true); + $.post(YoonePBAdmin.ajax_url, { + action: 'yoone_get_taxonomy_terms', + taxonomy: tax, + security: YoonePBAdmin.security + }).done(function(resp){ + if (resp && resp.success && Array.isArray(resp.data)) { + var items = resp.data; + $terms.empty(); + items.forEach(function(item){ + var opt = $('