15 lines
5.5 KiB
JavaScript
15 lines
5.5 KiB
JavaScript
jQuery(document).ready(function(){if(jQuery().select2){jQuery("#paczkomat_id").select2({});jQuery("#woocommerce_paczkomaty_shipping_method_kurier_paczkomat_id").select2({})}
|
|
function woocommerce_paczkomaty_shipping_method_auto_create_change(){var woocommerce_paczkomaty_shipping_method_order_status=jQuery('#woocommerce_paczkomaty_shipping_method_order_status');if(jQuery('#woocommerce_paczkomaty_shipping_method_auto_create').val()==='manual'){woocommerce_paczkomaty_shipping_method_order_status.closest('tr').hide()}else{woocommerce_paczkomaty_shipping_method_order_status.closest('tr').show()}}
|
|
function woocommerce_paczkomaty_shipping_method_test_mode_change(){kurier_fields_change();paczkomaty_fields_change()}
|
|
jQuery('#woocommerce_paczkomaty_shipping_method_test_mode').click(woocommerce_paczkomaty_shipping_method_test_mode_change);jQuery('#woocommerce_paczkomaty_shipping_method_kurier_webhook_url').attr('readonly',!0);jQuery('#woocommerce_paczkomaty_shipping_method_auto_create').change(woocommerce_paczkomaty_shipping_method_auto_create_change);woocommerce_paczkomaty_shipping_method_test_mode_change();woocommerce_paczkomaty_shipping_method_auto_create_change();function kurier_fields_change(){var test_mode_shipx=jQuery('.test_mode_shipx');if(jQuery('#woocommerce_paczkomaty_shipping_method_test_mode').is(':checked')){test_mode_shipx.closest('tr').show()}else{test_mode_shipx.closest('tr').hide()}
|
|
jQuery('#woocommerce_paczkomaty_shipping_method_kurier_webhook_token').closest('tr').hide()}
|
|
function paczkomaty_fields_change(){if(jQuery('#woocommerce_paczkomaty_shipping_method_paczkomaty').is(':checked')){jQuery('h3.paczkomaty').show();jQuery('#woocommerce_paczkomaty_shipping_method_polecony_sender_data').next().show();jQuery('.paczkomaty').closest('tr').show();var test_mode_paczkomaty=jQuery('.test_mode_paczkomaty');if(jQuery('#woocommerce_paczkomaty_shipping_method_test_mode').is(':checked')){test_mode_paczkomaty.closest('tr').show()}else{test_mode_paczkomaty.closest('tr').hide()}}else{jQuery('h3.paczkomaty').hide();jQuery('#woocommerce_paczkomaty_shipping_method_polecony_sender_data').next().hide();jQuery('.paczkomaty').closest('tr').hide()}}
|
|
function shipX_services_field_change(){if(typeof shipX_connection_status!=='undefined'){var organization_id=jQuery('#woocommerce_paczkomaty_shipping_method_organization_id').val();var services_html='';var is_active=!1;jQuery(shipX_services).each(function(index,value){is_active=!1;let service_label=value.name+' ('+value.id+')';jQuery(shipX_organizations).each(function(organization_index,organization){if(organization.id==organization_id){jQuery(organization.services).each(function(service_index,service){if(value.id==service){if(services_html!==''){services_html=services_html+'<br/>'}
|
|
services_html=services_html+'<span class="available '+value.id+'">'+service_label+': usługa dostępna'+'</span>';is_active=!0}})}});if(!is_active){if(services_html!==''){services_html=services_html+'<br/>'}
|
|
services_html=services_html+'<span class="not-available '+value.id+'">'+service_label+': usługa niedostępna'+'</span>'}});jQuery('#woocommerce_paczkomaty_shipping_method_services').html(services_html)}}
|
|
function shipX_fields_change(){if(typeof shipX_connection_status!=='undefined'&&shipX_connection_status==='not_connected'){jQuery('input.shipx,select.shipx').prop('readonly',!0);jQuery('input.shipx,select.shipx').prop('disabled',!0);jQuery('select.shipx option:not(:selected)').attr('disabled',!0)}}
|
|
function send_method_fields_change(){var send_method_value=jQuery('#woocommerce_paczkomaty_shipping_method_sending_method').val();jQuery('.sending_method').closest('tr').hide();jQuery('.sending_method_'+send_method_value).closest('tr').show()}
|
|
function sender_address_fields_change(){if(jQuery('#woocommerce_paczkomaty_shipping_method_sender_address').is(':checked')){jQuery('.sender_address').closest('tr').show()}else{jQuery('.sender_address').closest('tr').hide()}}
|
|
function dispatch_point_fields_change(){let val=jQuery('#woocommerce_paczkomaty_shipping_method_dispatch_point').val();jQuery('.dispatch-point').closest('tr').toggle(val==='custom');jQuery('.dispatch-point-required').prop('required',val==='custom')}
|
|
kurier_fields_change();paczkomaty_fields_change();send_method_fields_change();sender_address_fields_change();shipX_fields_change();dispatch_point_fields_change();shipX_services_field_change();jQuery('#woocommerce_paczkomaty_shipping_method_kurier').change(kurier_fields_change);jQuery('#woocommerce_paczkomaty_shipping_method_paczkomaty').change(paczkomaty_fields_change);jQuery('#woocommerce_paczkomaty_shipping_method_dispatch_point').change(dispatch_point_fields_change);var woocommerce_paczkomaty_shipping_method_connection_status=jQuery('#woocommerce_paczkomaty_shipping_method_connection_status');if(woocommerce_paczkomaty_shipping_method_connection_status.length){woocommerce_paczkomaty_shipping_method_connection_status.html(shipX_connection_message);if(shipX_connection_status==='connected'){woocommerce_paczkomaty_shipping_method_connection_status.addClass('shipX_status_connected')}else{woocommerce_paczkomaty_shipping_method_connection_status.addClass('shipX_status_not_connected')}}
|
|
jQuery('#woocommerce_paczkomaty_shipping_method_organization_id').change(shipX_services_field_change);jQuery('#woocommerce_paczkomaty_shipping_method_sending_method').change(send_method_fields_change);jQuery('#woocommerce_paczkomaty_shipping_method_sender_address').change(sender_address_fields_change);jQuery('.select2').select2({minimumResultsForSearch:5});jQuery('#mainform').submit(function(){jQuery('input.shipx,select.shipx').prop('disabled',!1)})}) |