PageSourceSearch

https://tapksveikas.lt/wp-content/plugins/woo-payment-gateway-pays…/assets/js/delivery/frontend.js?ver=5.4.23

js tapksveikas.lt collected 2026-10-04 22:12:37 UTC 10,156 bytes, 181 lines download raw bytes

1jQuery(document).ready(function($) {
2    $('.paysera-delivery-terminal-city-selection').select2();
3    $('.paysera-delivery-terminal-country-selection').select2();
4    $('.paysera-delivery-terminal-location-selection').select2();
5
6    $(document).on( 'added_to_cart removed_from_cart updated_cart_totals', function () {
7        $('.paysera-delivery-error').each(function () {
8            $(this).parent().parent().children().attr('disabled', true);
9        });
10    });
11
12    $(document).on('updated_checkout cfw_updated_checkout', function () {
13        let shippingCountryId, shippingCountry, shippingCity, shippingCountryOption, shippingState;
14
15        let isShippingToAnotherAddressEnabled = $('#ship-to-different-address-checkbox').is(':checked');
16
17        shippingCountry = $('#billing_country');
18        shippingCity = $('#billing_city').val();
19        shippingState = $('#billing_state').val();
20
21        if (isShippingToAnotherAddressEnabled === true) {
22            shippingCountry = $('#shipping_country');
23            shippingCity = $('#shipping_city').val();
24            shippingState = $('#shipping_state').val();
25        }
26
27        $('.paysera-delivery-error').each(function () {
28            $(this).parent().parent().children().attr('disabled', true);
29        });
30
31        shippingCountryOption = shippingCountry.find('option');
32        shippingCountryId = shippingCountry.val();
33
34        if (typeof shippingCountry.val() === 'undefined' || shippingCountry.val() === null) {
35            shippingCountryId = shippingCountryOption.eq(1).val();
36        }
37
38        let paysera_terminal_country = $('.paysera-delivery-terminal-country');
39        let paysera_terminal_country_selection = $('.paysera-delivery-terminal-country-selection');
40        let shipping_methods = {};
41
42        $('select.shipping_method, input[name^="shipping_method"][type="radio"]:checked, input[name^="shipping_method"][type="hidden"]').each(function () {
43            shipping_methods[$(this).data('index')] = $(this).val();
44        });
45
46        if (Object.keys(shipping_methods).length > 0) {
47            let shipping_methods_keys = Object.keys(shipping_methods);
48            let shipping_method = $.trim(shipping_methods[shipping_methods_keys[0]]);
49            let paysera_delivery_method = 'paysera_delivery';
50
51            if (shipping_method.indexOf(paysera_delivery_method) !== -1) {
52                paysera_terminal_country_selection.val('default');
53                paysera_terminal_country_selection.trigger('change');
54                let paysera_delivery_terminal_method = 'terminal';
55
56                if (shipping_method.indexOf(paysera_delivery_terminal_method) !== -1) {
57                    paysera_terminal_country_selection.empty();
58                    $.ajax({
59                        type: 'POST',
60                        url: ajax_object.ajaxurl,
61                        data: {
62                            action: 'change_paysera_method',
63                            shipping_method: shipping_method
64                        },
65                        success:function(response) {
66                            let countries = JSON.parse(response);
67                            let newOption = new Option(countries['default'], 'default', true, true);
68                            paysera_terminal_country_selection.append(newOption).trigger('change');
69
70                            $.each(countries, function(index, item) {
71                                if (index === 'default') {
72                                    return;
73                                }
74
75                                let newCountryOption;
76
77                                if (index === shippingCountryId) {
78                                    newCountryOption = new Option(item, index, false, true);
79
80                                    let city_container = $('.paysera-delivery-terminal-city');
81
82                                    $.ajax({
83                                        type: 'POST',
84                                        url: ajax_object.ajaxurl,
85                                        data: {
86                                            action: 'change_paysera_country',
87                                            country: shippingCountryId,
88                                            shipping_method: shipping_method
89                                        },
90                                        success:function(response) {
91                                            let cities = JSON.parse(response);
92                                            let newOption = new Option(cities['default'], 'default', true, true);
93                                            $('.paysera-delivery-terminal-city-selection').append(newOption).trigger('change');
94
95                                            $.each(cities, function(index, item) {
96                                                if (index === 'default') {
97                                                    return;
98                                                }
99
100                                                let newCityOption;
101
102                                                if (item === shippingCity || item === shippingState || item === shippingState + ' apskr.') {
103                                                    let location_container = $('.paysera-delivery-terminal-location');
104                                                    let cityData;
105
106                                                    if (item === shippingCity) {
107                                                        cityData = shippingCity;
108                                                    } else if (item === shippingState) {
109                                                        cityData = shippingState;
110                                                    } else {
111                                                        cityData = shippingState + ' apskr.';
112                                                    }
113
114                                                    newCityOption = new Option(item, index, false, true);
115
116                                                    $.ajax({
117                                                        type: 'POST',
118                                                        url: ajax_object.ajaxurl,
119                                                        data: {
120                                                            action: 'change_paysera_city',
121                                                            country: $('.paysera-delivery-terminal-country-selection').select2('data')[0]['id'],
122                                                            city: cityData,
123                                                            shipping_method: shipping_method
124                                                        },
125                                                        success:function(response) {
126                                                            let terminals = JSON.parse(response);
127                                                            let newOption = new Option(terminals['default'], 'default', true, true);
128                                                            $('.paysera-delivery-terminal-location-selection').append(newOption).trigger('change');
129
130                                                            $.each(terminals, function(index, item) {
131                                                                if (index === 'default') {
132                                                                    return;
133                                                                }
134                                                                let newOption = new Option(item, index, false, false);
135                                                                $('.paysera-delivery-terminal-location-selection').append(newOption).trigger('change');
136                                                            });
137
138                                                            location_container.show();
139                                                        },
140                                                        error:function() {
141                                                            alert('There was an error while fetching the data.');
142                                                        }
143                                                    });
144                                                } else {
145                                                    newCityOption = new Option(item, index, false, false);
146                                                }
147
148                                                $('.paysera-delivery-terminal-city-selection').append(newCityOption).trigger('change');
149                                            });
150
151                                            city_container.show();
152                                        },
153                                        error:function() {
154                                            alert('There was an error while fetching the data.');
155                                        }
156                                    });
157                                } else {
158                                    newCountryOption = new Option(item, index, false, false);
159                                }
160
161                                paysera_terminal_country_selection.append(newCountryOption).trigger('change');
162                            });
163                        },
164                        error:function() {
165                            alert('There was an error while fetching the data.');
166                        }
167                    });
168                    paysera_terminal_country.show();
169                } else {
170                    paysera_terminal_country.hide();
171                }
172            } else {
173                paysera_terminal_country.hide();
174            }
175            $('.paysera-delivery-terminal-city').hide();
176            $('.paysera-delivery-terminal-location').hide();
177            $('.paysera-delivery-terminal-city-selection').empty();
178            $('.paysera-delivery-terminal-location-selection').empty();
179        }
180    });
181});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.