PageSourceSearch

https://thepaisleybox.com/wp-content/plugins/woocommerce-tm-extra-…/assets/js/cp-subscriptions.js?ver=4.9.7

js thepaisleybox.com collected 2026-09-26 18:57:10 UTC 8,060 bytes, 206 lines download raw bytes

1(function (window, document, $) {
2    "use strict";
3
4    var TMEPOJS;
5
6    function tm_set_subscription_period(epoObject) {
7
8        var cart_id;
9        var $cart;
10        var subscription_period;
11        var variations_subscription_period;
12        var base;
13        var is_subscription;
14        var is_hidden;
15        var variation_id_selector;
16        var current_variation;
17        var $_cart;
18        var subscription_period_separator;
19        var this_epo_totals_container = epoObject.this_epo_totals_container;
20        var main_product = epoObject.main_product;
21
22        this_epo_totals_container.each(function () {
23            cart_id = $(this).attr("data-cart-id");
24            $cart = main_product.find(".tm-extra-product-options.tm-cart-" + cart_id);
25            subscription_period = $(this).data("subscription-period");
26            variations_subscription_period = $(this).data("variations-subscription-period");
27            base = $cart.find(".tmcp-field").closest(".tmcp-field-wrap");
28            is_subscription = $(this).data("is-subscription");
29
30            if (is_subscription) {
31                base.find(".tmperiod").remove();
32
33                is_hidden = base.find(".amount").is(".hidden");
34                if (is_hidden) {
35                    is_hidden = " hidden";
36                } else {
37                    is_hidden = "";
38                }
39
40                variation_id_selector = "input[name^='variation_id']";
41                $_cart = $(this).data("tm_for_cart");
42
43                if ($_cart) {
44                    if ($_cart.find("input.variation_id").length > 0) {
45                        variation_id_selector = "input.variation_id";
46                    }
47                    current_variation = $_cart.find(variation_id_selector).val();
48                    if (!current_variation) {
49                        current_variation = 0;
50                    }
51                    if (variations_subscription_period[$.epoAPI.math.toFloat(current_variation)]) {
52                        subscription_period = variations_subscription_period[$.epoAPI.math.toFloat(current_variation)];
53                    }
54                }
55                subscription_period_separator = " / ";
56                if (window.subscription_period_separator !== undefined) {
57                    subscription_period_separator = window.subscription_period_separator;
58                }
59                base.find(".amount").after("<span class=\"tmperiod" + is_hidden + "\">" + subscription_period_separator + subscription_period + "</span>");
60
61                $(this).find(".tmperiod").remove();
62                $(this).find(".amount.options").after("<span class=\"tmperiod\">" + subscription_period_separator + subscription_period + "</span>");
63                $(this).find(".amount.final").after("<span class=\"tmperiod\">" + subscription_period_separator + subscription_period + "</span>");
64            }
65        });
66
67    }
68
69    /**
70     * Adjust totals object
71     *
72     * @since  1.0
73     * @return String
74     */
75    function tc_adjust_tc_totals_ob(tc_totals_ob, data) {
76
77        var subscription_options_total = 0;
78        var formatted_subscription_fee_total = "";
79        var subscription_sign_up_fee;
80        var subscription_total;
81        var show_sign_up_fee = false;
82        var showTotal = data.showTotal;
83        var epoHolder = data.epoHolder;
84        var totalsHolder = data.totalsHolder;
85        var tm_set_price_totals = data.tm_set_price_totals;
86
87        epoHolder.find(".tmcp-sub-fee-field").filter(".tcenabled").toArray().forEach(function (field) {
88
89            var option_price = 0;
90            var options;
91
92            field = $(field);
93
94            if (field.is(":checkbox, :radio, :input")) {
95
96                if (field.is(".tmcp-checkbox, .tmcp-radio")) {
97                    if (field.is(":checked")) {
98                        option_price = field.data("raw_price");
99                        showTotal = true;
100                        field.data("isset", 1);
101                    } else {
102                        field.data("isset", 0);
103                    }
104                } else if (field.is(".tmcp-select")) {
105                    option_price = field.find("option:selected").data("raw_price");
106                    options = field.children("option:selected");
107                    if (!(options.val() === "" && options.attr("data-rulestype") === "")) {
108                        showTotal = true;
109                    }
110                    field.find("option").data("isset", 0);
111                    field.find("option:selected").data("isset", 1);
112                } else {
113                    if (field.val()) {
114                        option_price = field.data("raw_price");
115                        showTotal = true;
116                        field.data("isset", 1);
117                    } else {
118                        field.data("isset", 0);
119                    }
120                }
121                if (!option_price) {
122                    option_price = 0;
123                }
124
125                if (field.is(".tmcp-sub-fee-field")) {
126                    subscription_options_total = parseFloat(subscription_options_total) + parseFloat(option_price);
127                }
128
129            }
130
131        });
132
133        if (totalsHolder.data("is-subscription")) {
134            subscription_sign_up_fee = parseFloat(totalsHolder.data("subscription-sign-up-fee"));
135            if (!Number.isFinite(subscription_sign_up_fee)) {
136                subscription_sign_up_fee = 0;
137            }
138            subscription_total = subscription_sign_up_fee + parseFloat(subscription_options_total);
139            if (subscription_total) {
140                show_sign_up_fee = true;
141                formatted_subscription_fee_total = tm_set_price_totals(subscription_total, totalsHolder, false, true);
142            }
143        }
144
145        tc_totals_ob.formatted_subscription_fee_total = formatted_subscription_fee_total;
146        tc_totals_ob.show_sign_up_fee = show_sign_up_fee;
147        tc_totals_ob.sign_up_fee = TMEPOJS.i18n_sign_up_fee;
148        tc_totals_ob.showTotal = showTotal;
149
150        return tc_totals_ob;
151
152    }
153
154    $(document).ready(function () {
155
156        TMEPOJS = window.TMEPOJS || null;
157
158        if (!TMEPOJS) {
159            return;
160        }
161
162        $(window).on("tm-epo-init-end", function (event, eventData) {
163            if (event && eventData && eventData.epo) {
164                tm_set_subscription_period(eventData.epo);
165            }
166        });
167
168        $(window).on("tc-epo-after-update", function (event, eventData) {
169            if (event && eventData && eventData.data && eventData.data.epo_object) {
170                tm_set_subscription_period(eventData.data.epo_object);
171            }
172        });
173
174        $(window).on("tm-epo-found-variation", function (event, eventData) {
175
176            var totalsHolder;
177            var variation;
178            var variations;
179
180            if (event && eventData && eventData.epo) {
181
182                totalsHolder = eventData.totalsHolder;
183                variation = eventData.variation;
184                variations = totalsHolder.data("variations");
185
186                if (variations && variation && variation.variation_id) {
187                    if (variation.tc_subscription_sign_up_fee !== undefined) {
188                        totalsHolder.data("subscription-sign-up-fee", variation.tc_subscription_sign_up_fee);
189                    } else {
190                        totalsHolder.data("subscription-sign-up-fee", 0);
191                    }
192
193                    if (variation.tc_subscription_period !== undefined) {
194                        totalsHolder.data("subscription-period", variation.tc_subscription_period);
195                    }
196                }
197
198            }
199
200        });
201
202        $.epoAPI.addFilter("tc_adjust_tc_totals_ob", tc_adjust_tc_totals_ob, 10, 2);
203
204    });
205
206}(window, document, window.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.