PageSourceSearch

https://www.puntoqpack.com/personalizados/modules/codfee/views/js/codfee17.js?v=2

js puntoqpack.com collected 2026-10-04 11:31:15 UTC 21,271 bytes, 303 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 2023 idnovate
20*  @license   See above
21*/
22
23function updateTotalsWithFeeCod() {
24    var js_checkout_summary = '';
25    if (typeof $('#js-checkout-summary') !== 'undefined') {
26        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 $('#js-checkout-summary .cart-summary-line#cart-total') !== 'undefined') {
30        total_ori_html = $(js_checkout_summary + '.cart-summary-line#cart-total').last().html();
31    }
32    if (typeof $('.cart-summary-line.cart-total_2').last().html() === 'undefined') {
33        if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
34            if($(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').text() != '') {
35                var total_ori_without_taxes_html = $(js_checkout_summary + '.cart-summary-totals div').last().prev().html();
36            }
37        } else {
38            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();
39        }
40
41    } else {
42        var total_ori_without_taxes_html = $('.cart-summary-line.cart-total_2').last().html();
43    }
44    if (typeof $('.cart-summary-line.cart-total').next().html() === 'undefined') {
45        var taxes_ori_html = $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html();
46        if ($('#cart-subtotal-tax')) {
47            var taxes_ori_html = $('#cart-subtotal-tax').find('span.value').html();
48        }
49    } else {
50        var taxes_ori_html = $(js_checkout_summary + '.cart-summary-line.cart-total').next().html();
51    }
52    $("input[name='payment-option']").click(function() {
53    //$(document).on('change', 'input[name="payment-option"]', function(e) {
54        var codfee_id = $('#pay-with-' + this.id + '-form').find('input[name=codfee_id]').val();
55        if (codfee_id != null && typeof codfee_id !== 'undefined') {
56            var conditions_checkbox = $("input[name='cgv']");
57            if ($("input[name='cgv']").size() == 0) {
58                conditions_checkbox = $("input[name='conditions_to_approve[terms-and-conditions]']");
59            }
60            if (conditions_checkbox.size() == 0 || $("input[name='conditions_to_approve[terms-and-conditions]']").is(':checked')) {
61                //document.querySelector('#payment-confirmation article').style.display = 'none';
62                document.querySelector('#payment-confirmation button').removeAttribute('disabled');
63            }
64        }
65        if (codfee_id != null && typeof codfee_id !== 'undefined' && $("input[name='codfee_type_" + codfee_id + "']").val() != '3') {
66            /* Order fees
67            $(this).on('change', function() { return false; });
68            $(this).off('change');
69            $('.cart-payment-discount').remove();
70            setTimeout(function() { 
71                $('.order-confirmation-table .cart-order-summary-codfee').prev().remove();
72            }, 1000);
73            $('.js-additional-information.definition-list.additional-information, .js-payment-option-form').each(function() {
74                $(this).css('display', 'none');
75            });
76            $('#' + this.id + '-additional-information').css('display', 'block');
77            */
78            setTimeout(function() { 
79                $('#cart-subtotal-codfee').remove();
80                /*$('#cart-subtotalsum-codfee').remove();*/
81                if ($("input[name='codfee_free_flag_" + codfee_id + "']").val() == '1') {
82                    $("input[name='codfee_fee_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
83                    $("input[name='codfee_fee_wt_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
84                }
85                if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
86                    $('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-codfee">' +
87                        '<span class="label cart-summary-codfee-label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
88                        '<span class="value">' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span>' +
89                        '</div>').insertAfter(js_checkout_summary + '#cart-subtotal-shipping');
90                } else {
91                    $('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-codfee">' +
92                        '<span class="label cart-summary-codfee-label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
93                        '<span class="value">' + $("input[name='codfee_fee_wt_" + codfee_id + "']").val() + '</span>' +
94                        '</div>').insertAfter(js_checkout_summary + '#cart-subtotal-shipping');
95                }
96                /*$('<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotalsum-codfee">' +
97                    '<span class="label">' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</span>' +
98                    '<span class="value">' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span>' +
99                    '</div>').insertBefore($('.cart-summary-line.cart-total').prev());*/
100                if (typeof $('.cart-summary-line.cart-total_2').last().html() === 'undefined') {
101                    $(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());
102                } else {
103                    $('.cart-summary-line.cart-total_2').find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
104                }
105                if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
106                    $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
107                    $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('strong.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
108                    if (typeof $('#js-checkout-summary .cart-summary-line#cart-total') !== 'undefined') {
109                        if ($(js_checkout_summary + '.cart-summary-line#cart-total').last().find('span.value b').length > 0) {
110                            $(js_checkout_summary + '.cart-summary-line#cart-total').last().find('span.value b').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
111                        } else {
112                            $(js_checkout_summary + '.cart-summary-line#cart-total').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
113                        }
114                        $(js_checkout_summary + '.cart-summary-line#cart-total').last().find('strong.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
115                    }
116                } else {
117                    if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
118                        if($(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').text() != '') {
119                            $(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
120                        }
121                        if($(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').text() != '') {
122                            $(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
123                        }
124                    } else if ($(js_checkout_summary + '.cart-summary-totals div').length == 3) {
125                        if($(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').text() != '') {
126                            $(js_checkout_summary + '.cart-summary-totals div').last().prev().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
127                        }
128                        if($(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').text() != '') {
129                            $(js_checkout_summary + '.cart-summary-totals div').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
130                        }
131                    } else if ($(js_checkout_summary + '.cart-summary-totals div').length == 5) {
132                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().prev().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
133                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().prev().find('strong.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
134                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('span.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
135                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('strong.value').html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
136                    } else {
137                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('span.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
138                        $(js_checkout_summary + '.cart-summary-line.cart-total').last().find('strong.value').html($("input[name='codfee_total_without_taxes_" + codfee_id + "']").val());
139                    }
140                }
141                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
142                    if ($(js_checkout_summary + '.cart-summary-line.cart-total').next().find('span.value').text() != "") {
143                        $(js_checkout_summary + '.cart-summary-line.cart-total').next().find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
144                    }
145                    if (typeof $('.cart-summary-line.cart-total_2').last().html() !== 'undefined') {
146                        $(js_checkout_summary + '.cart-summary-line.cart-total').prev().find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
147                    }
148                    if ($('#cart-subtotal-tax').size() > 0) {
149                        $('.cart-summary-codfee-label').removeClass('label');
150                        $('#cart-subtotal-tax').find('span.value').html($("input[name='codfee_taxes_" + codfee_id + "']").val());
151                    }
152                }
153            }, 100);
154        } else if ($(this).attr('data-module-name') != 'paypalwithfee' && $(this).is(':checked')) {
155                /*
156                $('#' + this.id + '-additional-information').css('display', 'none');
157                */
158                $('#cart-subtotal-codfee').remove();
159                /*$('#cart-subtotalsum-codfee').remove();*/
160                $(js_checkout_summary + '.cart-summary-line.cart-total').last().html(total_ori_html);
161                if (typeof $('#js-checkout-summary .cart-summary-line#cart-total') !== 'undefined') {
162                    $(js_checkout_summary + '.cart-summary-line#cart-total').last().html(total_ori_html);
163                }
164                if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total_2').last().html() === 'undefined') {
165                    if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
166                        $(js_checkout_summary + '.cart-summary-totals div').last().prev().html(total_ori_without_taxes_html);
167                    } else {
168                        $(js_checkout_summary + '.cart-summary-totals .cart-summary-line.cart-total').last().prevAll('.cart-summary-line.cart-total').html(total_ori_without_taxes_html);
169                    }
170                } else {
171                    $(js_checkout_summary + '.cart-summary-line.cart-total_2').first().html(total_ori_without_taxes_html);
172                }
173                if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total').next().html() === 'undefined') {
174                    $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html(taxes_ori_html);
175                    if ($('#cart-subtotal-tax').size() > 0) {
176                        $('#cart-subtotal-tax').find('span.value').html(taxes_ori_html);
177                    }
178                } else {
179                    $(js_checkout_summary + '.cart-summary-line.cart-total').next().html(taxes_ori_html);
180                }
181        } else {
182            /*
183            $('#' + this.id + '-additional-information').css('display', 'none');
184            */
185            $(js_checkout_summary + '#cart-subtotal-codfee').remove();
186            /*$('#cart-subtotalsum-codfee').remove();*/
187            //$(js_checkout_summary + '.cart-summary-line.cart-total').first().html(total_ori_html);
188            $(js_checkout_summary + '.cart-summary-line.cart-total_2').first().html(total_ori_without_taxes_html);
189            if ($(js_checkout_summary + '.cart-summary-totals div').length == 2) {
190                $(js_checkout_summary + '.cart-summary-totals div').last().prev().html(total_ori_without_taxes_html);
191            }
192            if (typeof $(js_checkout_summary + '.cart-summary-line.cart-total').next().html() === 'undefined') {
193                $(js_checkout_summary + '.cart-summary-line.cart-total').prev().html(taxes_ori_html);
194            } else {
195                $(js_checkout_summary + '.cart-summary-line.cart-total').next().html(taxes_ori_html);
196            }
197            $(js_checkout_summary + '.cart-summary-line.cart-total').last().html(total_ori_html);
198            if (typeof $('#js-checkout-summary .cart-summary-line#cart-total') !== 'undefined') {
199                $(js_checkout_summary + '.cart-summary-line#cart-total').last().html(total_ori_html);
200            }
201        }
202    });
203}
204
205function updateOrderSummaryWithFeeCod() {
206    var ps176 = false;
207    var ps1761 = false;
208    if (typeof $('.order-confirmation-table .order-confirmation-total').html() !== 'undefined') {
209        ps1761 = true;
210        var table_totals = $('.order-confirmation-table div');
211        var total_ori_html = table_totals.last().html();
212        var taxes_ori_html = table_totals.last().prev().prev().html();
213    } else if (typeof $('.order-confirmation-table .taxes').html() === 'undefined') {
214        var total_ori_html = $('.order-confirmation-table table tr td').last().html();
215        var taxes_ori_html = $('.order-confirmation-table table tr').last().prev().last().html();
216    } else {
217        ps176 = true;
218        var total_ori_html = $('.order-confirmation-table table tr').last().prev().last().html();
219        var taxes_ori_html = $('.order-confirmation-table .taxes').html();
220    }
221    $("input[name='payment-option']").click(function() {
222        var codfee_id = $('#pay-with-' + this.id + '-form').find('input[name=codfee_id]').val();
223        if (codfee_id != null && $("input[name='codfee_type_" + codfee_id + "']").val() != '3') {
224            $('tr.cart-order-summary-codfee, div.cart-order-summary-codfee').remove();
225            if ($("input[name='codfee_free_flag_" + codfee_id + "']").val() == '1') {
226                $("input[name='codfee_fee_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
227                $("input[name='codfee_fee_wt_" + codfee_id + "']").val($("input[name='codfee_free_txt_" + codfee_id + "']").val());
228            }
229            if ($("input[name='codfee_price_display_method_cartsummary_" + codfee_id + "']").val() == '1') {
230                $('<tr class="cart-order-summary-codfee">' +
231                    '<td>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</td>' +
232                    '<td>' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</td>' +
233                    '</tr>').insertBefore($('.order-confirmation-table table tr').last().prev().prev());
234                if (ps1761) {
235                    $('<div class="col-8 cart-order-summary-codfee text-right">' +
236                        '<label>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</label></div>' +
237                        '<div class="col-4 cart-order-summary-codfee text-right"><span class="price price-normal">
237' + $("input[name='codfee_fee_" + codfee_id + "']").val() + '</span></div>' +
238                        '').insertBefore(table_totals.last().prev().prev().prev());
239                }
240            } else {
241                $('<tr class="cart-order-summary-codfee">' +
242                    '<td>' + $("input[name='codfee_text_" + codfee_id + "']").val() + '</td>' +
243                    '<td>' + $("input[name='codfee_fee_wt_" + codfee_id + "']").val() + '</td>' +
244                    '</tr>').insertBefore($('.order-confirmation-table table tr').last().prev());
245            }
246            if (ps176) {
247                $('.order-confirmation-table table tr').last().prev().find('td').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
248                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
249                    $('.order-confirmation-table .taxes').find('td span').last().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
250                }
251            } else if (ps1761) {
252                $('.order-confirmation-table div span').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
253                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
254                    table_totals.last().prev().prev().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
255                }
256            } else {
257                $('.order-confirmation-table table tr td').last().html($("input[name='codfee_total_with_taxes_" + codfee_id + "']").val());
258                if ($("input[name='codfee_tax_enabled_" + codfee_id + "']").val() == '1' && $("input[name='codfee_tax_display_" + codfee_id + "']").val() == '1') {
259                    $('.order-confirmation-table table tr').last().prev().find('td').last().html($("input[name='codfee_taxes_" + codfee_id + "']").val());
260                }
261            }
262        } else {
263            $('tr.cart-order-summary-codfee, div.cart-order-summary-codfee').remove();
264            if (ps176) {
265                $('.order-confirmation-table table tr').last().prev().last().html(total_ori_html);
266                $('.order-confirmation-table .taxes').html(taxes_ori_html);
267            } else if (ps1761) {
268                table_totals.last().html(total_ori_html);
269                table_totals.last().prev().prev().html(taxes_ori_html);
270            } else {
271                $('.order-confirmation-table table tr td').last().html(total_ori_html);
272                $('.order-confirmation-table table tr').last().prev().last().html(taxes_ori_html);
273            }
274        }
275    });
276}
277
278$(document).ready(function() {
279    /*
280    $("input[name='payment-option']").each(function() {
281        if ($(this).attr('data-module-name') === 'codfee') {
282            $(this).on('change', function() {return false;});
283        }
284    });
285    */
286    updateTotalsWithFeeCod();
287    updateOrderSummaryWithFeeCod();
288    if ($('input[data-module-name=codfee]:checked').attr('checked') === 'checked') {
289        $('input[data-module-name=codfee]').click();
290    }
291    /*
292    if (typeof prestashop !== 'undefined') {
293        prestashop.on('updatedCart', function() {
294            if ($('input[data-module-name=codfee]:checked').length > 0) {
295                window.location.replace(window.location.href + '?codfee');
296            }
297        });
298        if (window.location.href.indexOf("?codfee") !== -1) {
299            $('input[data-module-name=codfee]').click();
300        }
301    }
302    */
303});

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.