/* 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 $selectMode = $('#yoone_bundle_select_mode'); var $productsField = $('#yoone_bundle_products_list_field'); if (typeof YoonePBAdmin === 'undefined') { return; } 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 = $('