PageSourceSearch

https://www.grainandframe.com/wp-content/plugins/pi-woocommerce-or…/js/save-checkout-data.js?ver=3.3.11.9

js grainandframe.com collected 2026-10-06 16:28:29 UTC 4,283 bytes, 108 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    function saveCheckoutField() {
5
6        this.fields = ['pi_system_delivery_date', 'pi_delivery_time', 'billing_email', 'billing_first_name', 'billing_last_name', 'billing_phone', 'billing_company', 'shipping_first_name', 'shipping_last_name', 'shipping_company', 'order_comments', 'createaccount', 'ship-to-different-address-checkbox'];
7
8        this.init = function () {
9            this.detectChange();
10            this.setData();
11            this.pickupLocationChange();
12        }
13
14        this.detectChange = function () {
15            var parent = this;
16            jQuery(document).on("keyup keypress change", "#pi_system_delivery_date, #pi_delivery_time, #billing_email, #billing_phone, #createaccount, #ship-to-different-address-checkbox, input.input-text, textarea.input-text", function () {
17                parent.getCheckoutData();
18            });
19        }
20
21        this.getCheckoutData = function () {
22
23            var data;
24
25            var length = this.fields.length;
26            for (var i = 0; i < length; i++) {
27                var index = this.fields[i];
28                var element = jQuery("#" + index);
29                if (element.is(':checkbox')) {
30                    data = jQuery("#" + index).prop("checked");
31                } else if (index == 'pickup_location') {
32                    if (jQuery("select[name='pickup_location']").length) {
33                        data = jQuery("select[name='pickup_location']").val();
34                    } else if (jQuery("input[name='pickup_location']").length) {
35                        data = jQuery("input[name='pickup_location']:checked").val();
36                    } else {
37                        data = null;
38                    }
39
40                } else {
41                    data = jQuery("#" + index).val();
42                }
43                if (data !== "" && data != undefined) {
44                    localStorage.setItem("pisol_" + index, data);
45                } else if (data == "" && index != 'pi_system_delivery_date') {
46                    localStorage.removeItem("pisol_" + index);
47                }
48            }
49
50        }
51
52        this.setData = function () {
53
54
55            var length = this.fields.length;
56            for (var i = 0; i < length; i++) {
57                var field = this.fields[i];
58                this.setIndividualFields(field);
59            }
60
61        }
62
63        this.setIndividualFields = function (field) {
64            var data = localStorage.getItem("pisol_" + field);
65            var element = jQuery("#" + field);
66            var present_val = element.val();
67
68            if (element.is(':checkbox') && data != null && data != 'undefined' && data != "") {
69                if (data == "true") {
70                    element.prop('checked', true);
71                } else {
72                    element.prop('checked', false);
73                }
74            } else {
75                if (data != null && data != 'undefined' && data != "" && present_val != data) {
76                    if (field != 'pi_system_delivery_date') {
77                        element.val(data);
78                    }
79                }
80            }
81
82        }
83
84        this.pickupLocationChange = function () {
85            var parent = this;
86            jQuery(document).on('change', '.pisol-location-radio, select[name="pickup_location"]', function () {
87                var data = null;
88                if (jQuery("select[name='pickup_location']").length) {
89                    data = jQuery("select[name='pickup_location']").val();
90                } else if (jQuery("input[name='pickup_location']").length) {
91                    data = jQuery("input[name='pickup_location']:checked").val();
92                }
93                if (data !== "" && data != undefined && data != null) {
94                    localStorage.setItem("pisol_pickup_location", data);
95                } else if (data == "") {
96                    localStorage.removeItem("pisol_pickup_location");
97                }
98            });
99        }
100    }
101
102    jQuery(function ($) {
103        var saveCheckoutFieldObj = new saveCheckoutField();
104        saveCheckoutFieldObj.init();
105    });
106
107
108})(jQuery);

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.