56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<script type="text/javascript">
|
|
var shipX_connection_status = <?php echo json_encode( $connection_status ); ?>;
|
|
var shipX_connection_message = <?php echo json_encode( $connection_message ); ?>;
|
|
var shipX_organizations = <?php echo json_encode( $organizations ); ?>;
|
|
var shipX_services = <?php echo json_encode( $services ); ?>;
|
|
jQuery(document).ready(function(){
|
|
function setup_select_type_field() {
|
|
$select = jQuery("#woocommerce_paczkomaty_shipping_method_select_type");
|
|
$select_select = $select.find("option[value=select]");
|
|
$select_select2 = $select.find("option[value=select2]");
|
|
if ($select.val() !== 'select') {
|
|
$select_select.remove();
|
|
} else {
|
|
$select_select.prop('disabled', 'disabled');
|
|
}
|
|
if ($select.val() !== 'select2') {
|
|
$select_select2.remove();
|
|
} else {
|
|
$select_select2.prop('disabled', 'disabled');
|
|
}
|
|
}
|
|
|
|
function toggle_fields() {
|
|
const select_method_value = $select_method.val();
|
|
jQuery('#woocommerce_paczkomaty_shipping_method_select_type').closest('tr').toggle( false );
|
|
}
|
|
|
|
const $select_method = jQuery('#woocommerce_paczkomaty_shipping_method_select_method');
|
|
$select_method.change(function(){toggle_fields();});
|
|
|
|
toggle_fields();
|
|
|
|
setup_select_type_field();
|
|
|
|
const $sender_data = jQuery('#woocommerce_paczkomaty_shipping_method_sender_data');
|
|
const $sender_data_custom = jQuery('.sender_data_custom');
|
|
|
|
function sender_data() {
|
|
const sender_data_val = $sender_data.val();
|
|
if (sender_data_val === 'custom') {
|
|
$sender_data_custom.closest('tr').show();
|
|
$sender_data_custom.prop('required', true);
|
|
} else {
|
|
$sender_data_custom.closest('tr').hide();
|
|
$sender_data_custom.prop('required', false);
|
|
}
|
|
}
|
|
|
|
$sender_data.change(function(){
|
|
sender_data();
|
|
});
|
|
|
|
sender_data();
|
|
});
|
|
</script>
|