PageSourceSearch

https://medvetsrl.it/modules/codfee/views/js/codfee17.js

js medvetsrl.it collected 2026-10-02 00:22:31 UTC 17,554 bytes, 265 lines download raw bytes

1/**
2* Cash On Delivery With Fee
3*
4* NOTICE OF LICENSE
5*
6* This product is licensed for one customer to use on one installation (test stores and multishop included).
7* Site developer has the right to modify this module to suit their needs, but can not redistribute the module in
8* whole or in part. Any other use of this module constitues a violation of the user agreement.
9*
10* DISCLAIMER
11*
12* NO WARRANTIES OF DATA SAFETY OR MODULE SECURITY
13* ARE EXPRESSED OR IMPLIED. USE THIS MODULE IN ACCORDANCE
14* WITH YOUR MERCHANT AGREEMENT, KNOWING THAT VIOLATIONS OF
15* PCI COMPLIANCY OR A DATA BREACH CAN COST THOUSANDS OF DOLLARS
16* IN FINES AND DAMAGE A STORES REPUTATION. USE AT YOUR OWN RISK.
17*
18*  @author    idnovate
19*  @copyright 2020 idnovate
20*  @license   See above
21*/
22
23function updateTotalsWithFee() {
24    var js_checkout_summary = '';
25    if (typeof $('#js-checkout-summary') !== 'undefined') {
26        var js_checkout_summary = '#js-checkout-summary ';
27    }
28    var total_ori_html = $(js_checkout_summary + '.cart-summary-line.cart-total').last().html();
29    if (typeof $('.cart-summary-line.cart-total_2').last().html() === 'undefined') {
30        if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
31            if($(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').text() != '') {
32                var total_ori_without_taxes_html = $(js_checkout_summary + '.cart-summary-totals div').last().prev().html();
33            }
34        } else {
35            var total_ori_without_taxes_html = $(js_checkout_summary + '.cart-summary-totals .cart-summary-line.cart-total').last().prevAll('.cart-summary-line.cart-total').html();
36        }
37
38    } else {
39        var total_ori_without_taxes_html = $('.cart-summary-line.cart-total_2').last().html();
40    }
41    if (typeof $('.cart-summary-line.cart-total').next().html() === 'undefined') {
42        var taxes_ori_html = $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html();
43        if ($('#cart-subtotal-tax')) {
44            var taxes_ori_html = $('#cart-subtotal-tax').find('span.value').html();
45        }
46    } else {
47        var taxes_ori_html = $(js_checkout_summary + '.cart-summary-line.cart-total').next().html();
48    }
49    $("input[name='payment-option']").click(function() {
50    //$(document).on('change', 'input[name="payment-option"]', function(e) {
51        var codfee_id = $('#pay-with-' + this.id + '-form').find('input[name=codfee_id]').val();
52        if (codfee_id != null && typeof codfee_id !== 'undefined') {
53            var conditions_checkbox = $("input[name='cgv']");
54            if ($("input[name='cgv']").size() == 0) {
55                conditions_checkbox = $("input[name='conditions_to_approve[terms-and-conditions]']");
56            }
57            if (conditions_checkbox.size() == 0 || $("input[name='conditions_to_approve[terms-and-conditions]']").is(':checked')) {
58                //document.querySelector('#payment-confirmation article').style.display = 'none';
59                document.querySelector('#payment-confirmation button').removeAttribute('disabled');
60            }
61        }
62        if (codfee_id != null && typeof codfee_id !== 'undefined' && $("input[name='codfee_type_" + codfee_id + "']").val() != '3') {
63            //$(this).on('change', function() { return false; });
64            /*
65            $('.js-additional-information.definition-list.additional-information, .js-payment-option-form').each(function() {
66                $(this).css('display', 'none');
67            });
68            $('#' + this.id + '-additional-information').css('display', 'block');
69            */
70            $('#cart-subtotal-codfee').remove();
71            /*$('#cart-subtotalsum-codfee').remove();*/
72            if ($("input[name='codfee_free_flag_" + codfee_id + "']").val() == '1') {
73                $("input[name='codfee_fee_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
74                $("input[name='codfee_fee_wt_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
75            }
76            if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
77                $('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-codfee">' +
78                    '<span class="label cart-summary-codfee-label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
79                    '<span class="value">' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span>' +
80                    '</div>').insertAfter(js_checkout_summary + '#cart-subtotal-shipping');
81            } else {
82                $('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-codfee">' +
83                    '<span class="label cart-summary-codfee-label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
84                    '<span class="value">' + $("input[name='codfee_fee_wt_" + codfee_id + "']").val() + '</span>' +
85                    '</div>').insertAfter(js_checkout_summary + '#cart-subtotal-shipping');
86            }
87            /*$('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotalsum-codfee">' +
88                '<span class="label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
89                '<span class="value">' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span>' +
90                '</div>').insertBefore($('.cart-summary-line.cart-total').prev());*/
91            if (typeof $('.cart-summary-line.cart-total_2').last().html() === 'undefined') {
92                $(js_checkout_summary + '.cart-summary-totals .cart-summary-line.cart-total').last().prevAll('.cart-summary-line.cart-total').find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
93            } else {
94                $('.cart-summary-line.cart-total_2').find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
95            }
96            if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
97                $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
98                $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('strong.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
99            } else {
100                if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
101                    if($(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').text() != '') {
102                        $(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
103                    }
104                    if($(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').text() != '') {
105                        $(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
106                    }
107                } else {
108                    $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
109                    $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('strong.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
110                }
111            }
112            if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
113                if ($(js_checkout_summary + '.cart-summary-line.cart-total').next().find('span.value').text() != "") {
114                    $(js_checkout_summary + '.cart-summary-line.cart-total').next().find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
115                }
116                if (typeof $('.cart-summary-line.cart-total_2').last().html() !== 'undefined') {
117                    $(js_checkout_summary + '.cart-summary-line.cart-total').prev().find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
118                }
119                if ($('#cart-subtotal-tax').size() > 0) {
120                    $('.cart-summary-codfee-label').removeClass('label');
121                    $('#cart-subtotal-tax').find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
122                }
123            }
124        } else if ($(this).attr('data-module-name') != 'paypalwithfee' && $(this).is(':checked')) {
125                /*
126                $('#' + this.id + '-additional-information').css('display', 'none');
127                */
128                $('#cart-subtotal-codfee').remove();
129                /*$('#cart-subtotalsum-codfee').remove();*/
130                $(js_checkout_summary + '.cart-summary-line.cart-total').last().html(total_ori_html);
131                if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total_2').last().html() === 'undefined') {
132                    if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
133                        $(js_checkout_summary + '.cart-summary-totals div').last().prev().html(total_ori_without_taxes_html);
134                    } else {
135                        $(js_checkout_summary + '.cart-summary-totals .cart-summary-line.cart-total').last().prevAll('.cart-summary-line.cart-total').html(total_ori_without_taxes_html);
136                    }
137                } else {
138                    $(js_checkout_summary + '.cart-summary-line.cart-total_2').first().html(total_ori_without_taxes_html);
139                }
140                if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total').next().html() === 'undefined') {
141                    $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html(taxes_ori_html);
142                    if ($('#cart-subtotal-tax').size() > 0) {
143                        $('#cart-subtotal-tax').find('span.value').html(taxes_ori_html);
144                    }
145                } else {
146                    $(js_checkout_summary + '.cart-summary-line.cart-total').next().html(taxes_ori_html);
147                }
148        } else {
149            /*
150            $('#' + this.id + '-additional-information').css('display', 'none');
151            */
152            $(js_checkout_summary + '#cart-subtotal-codfee').remove();
153            /*$('#cart-subtotalsum-codfee').remove();*/
154            //$(js_checkout_summary + '.cart-summary-line.cart-total').first().html(total_ori_html);
155            $(js_checkout_summary + '.cart-summary-line.cart-total_2').first().html(total_ori_without_taxes_html);
156            if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
157                $(js_checkout_summary + '.cart-summary-totals div').last().prev().html(total_ori_without_taxes_html);
158            }
159            if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total').next().html() === 'undefined') {
160                $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html(taxes_ori_html);
161            } else {
162                $(js_checkout_summary + '.cart-summary-line.cart-total').next().html(taxes_ori_html);
163            }
164            $(js_checkout_summary + '.cart-summary-line.cart-total').last().html(total_ori_html);
165        }
166    });
167}
168
169function updateOrderSummaryWithFee() {
170    var ps176 = false;
171    var ps1761 = false;
172    if (typeof $('.order-confirmation-table .order-confirmation-total').html() !== 'undefined') {
173        ps1761 = true;
174        var table_totals = $('.order-confirmation-table div');
175        var total_ori_html = table_totals.last().html();
176        var taxes_ori_html = table_totals.last().prev().prev().html();
177    } else if (typeof $('.order-confirmation-table .taxes').html() === 'undefined') {
178        var total_ori_html = $('.order-confirmation-table table tr td').last().html();
179        var taxes_ori_html = $('.order-confirmation-table table tr').last().prev().last().html();
180    } else {
181        ps176 = true;
182        var total_ori_html = $('.order-confirmation-table table tr').last().prev().last().html();
183        var taxes_ori_html = $('.order-confirmation-table .taxes').html();
184    }
185    $("input[name='payment-option']").click(function() {
186        var codfee_id = $('#pay-with-' + this.id + '-form').find('input[name=codfee_id]').val();
187        if (codfee_id != null && $("input[name='codfee_type_" + codfee_id + "']").val() != '3') {
188            $('tr.cart-order-summary-codfee').remove();
189            if ($("input[name='codfee_free_flag_" + codfee_id + "']").val() == '1') {
190                $("input[name='codfee_fee_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
191                $("input[name='codfee_fee_wt_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
192            }
193            if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
194                $('<tr class="cart-order-summary-codfee">' +
195                    '<td>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</td>' +
196                    '<td>' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</td>' +
197                    '</tr>').insertBefore($('.order-confirmation-table table tr').last().prev());
198                if (ps1761) {
199                    $('<div class="col-8 cart-order-summary-codfee">' +
200                        '<label>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</label></div>' +
201                        '<div class="col-4 cart-order-summary-codfee"><span class="price price-normal">
201' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span></div>' +
202                        '').insertBefore(table_totals.last().prev().prev().prev());
203                }
204            } else {
205                $('<tr class="cart-order-summary-codfee">' +
206                    '<td>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</td>' +
207                    '<td>' + $("input[name='codfee_fee_wt_" + codfee_id + "']").val() + '</td>' +
208                    '</tr>').insertBefore($('.order-confirmation-table table tr').last().prev());
209            }
210            if (ps176) {
211                $('.order-confirmation-table table tr').last().prev().find('td').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
212                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
213                    $('.order-confirmation-table .taxes').find('td span').last().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
214                }
215            } else if (ps1761) {
216                $('.order-confirmation-table div span').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
217                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
218                    table_totals.last().prev().prev().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
219                }
220            } else {
221                $('.order-confirmation-table table tr td').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
222                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
223                    $('.order-confirmation-table table tr').last().prev().find('td').last().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
224                }
225            }
226        } else {
227            $('tr.cart-order-summary-codfee, div.cart-order-summary-codfee').remove();
228            if (ps176) {
229                $('.order-confirmation-table table tr').last().prev().last().html(total_ori_html);
230                $('.order-confirmation-table .taxes').html(taxes_ori_html);
231            } else if (ps1761) {
232                table_totals.last().html(total_ori_html);
233                table_totals.last().prev().prev().html(taxes_ori_html);
234            } else {
235                $('.order-confirmation-table table tr td').last().html(total_ori_html);
236                $('.order-confirmation-table table tr').last().prev().last().html(taxes_ori_html);
237            }
238        }
239    });
240}
241
242$(document).ready(function() {
243    /*
244    $("input[name='payment-option']").each(function() {
245        if ($(this).attr('data-module-name') === 'codfee') {
246            $(this).on('change', function() {return false;});
247        }
248    });
249    */
250    updateTotalsWithFee();
251    updateOrderSummaryWithFee();
252    if ($('input[data-module-name=codfee]:checked').attr('checked') === 'checked') {
253        $('input[data-module-name=codfee]').click();
254    }
255    if (typeof prestashop !== 'undefined') {
256        prestashop.on('updatedCart', function() {
257            if ($('input[data-module-name=codfee]:checked').length > 0) {
258                window.location.replace(window.location.href + '?codfee');
259            }
260        });
261        if (window.location.href.indexOf("?codfee") !== -1) {
262            $('input[data-module-name=codfee]').click();
263        }
264    }
265});

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.