2025-12-31 00:38:29 +01:00
|
|
|
/**
|
|
|
|
|
* Admin JavaScript for Composable Products
|
|
|
|
|
*
|
|
|
|
|
* @package WC_Composable_Product
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
/**
|
|
|
|
|
* Show/hide product data tab for composable products
|
|
|
|
|
*/
|
|
|
|
|
$('select#product-type').on('change', function() {
|
|
|
|
|
const productType = $(this).val();
|
|
|
|
|
|
|
|
|
|
if (productType === 'composable') {
|
|
|
|
|
$('.show_if_composable').show();
|
|
|
|
|
$('.hide_if_composable').hide();
|
|
|
|
|
$('#composable_product_data').show();
|
|
|
|
|
$('.product_data_tabs .composable_options a').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.show_if_composable').hide();
|
|
|
|
|
$('#composable_product_data').hide();
|
|
|
|
|
$('.product_data_tabs .composable_options a').hide();
|
|
|
|
|
}
|
|
|
|
|
}).trigger('change');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Toggle criteria groups based on selected type
|
|
|
|
|
*/
|
|
|
|
|
$('#_composable_criteria_type').on('change', function() {
|
|
|
|
|
const criteriaType = $(this).val();
|
|
|
|
|
|
|
|
|
|
$('.composable_criteria_group').hide();
|
|
|
|
|
$('#composable_criteria_' + criteriaType).show();
|
|
|
|
|
}).trigger('change');
|
|
|
|
|
|
2025-12-31 21:01:52 +01:00
|
|
|
/**
|
|
|
|
|
* Toggle fixed price field based on pricing mode
|
|
|
|
|
*/
|
|
|
|
|
function toggleFixedPriceField() {
|
|
|
|
|
const pricingMode = $('#_composable_pricing_mode').val();
|
|
|
|
|
const $fixedPriceField = $('.composable_fixed_price_field');
|
|
|
|
|
|
|
|
|
|
if (pricingMode === 'fixed') {
|
|
|
|
|
$fixedPriceField.show();
|
|
|
|
|
} else {
|
|
|
|
|
$fixedPriceField.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#_composable_pricing_mode').on('change', toggleFixedPriceField);
|
|
|
|
|
toggleFixedPriceField();
|
|
|
|
|
|
2025-12-31 00:38:29 +01:00
|
|
|
/**
|
|
|
|
|
* Initialize enhanced select for categories and tags
|
|
|
|
|
*/
|
|
|
|
|
if ($.fn.selectWoo) {
|
|
|
|
|
$('#_composable_categories, #_composable_tags').selectWoo({
|
|
|
|
|
placeholder: 'Select options...',
|
|
|
|
|
allowClear: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery);
|