1/** 2 * We offer the best and most useful modules PrestaShop and modifications for your online store. 3 * 4 * We are experts and professionals in PrestaShop 5 * 6 * NOTICE OF LICENSE 7 * 8 * This file is not open source! Each license that you purchased is only available for 1 wesite only. 9 * If you want to use this file on more websites (or projects), you need to purchase additional licenses. 10 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. 11 * 12 * @author PresTeamShop SAS (Registered Trademark) <[email protected]> 13 * @copyright 2011-2023 PresTeamShop SAS, All rights reserved. 14 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 15 * 16 * @category PrestaShop 17 * @category Module 18 */ 19 20//Important note 21//If you want to trigger the events of the module elements, you must use 22//the exported variable window.jqueryOPC and not the jQuery of the template, for example: 23//window.jqueryOPC.find('#id_state').trigger('change'); 24 25function initOpcCompatibilities() { 26 if (typeof prestashop === typeof undefined) { 27 return; 28 } 29 30 let intervalPaymentToggleOrderButtonValidation = null; 31 32 //App - Events 33 prestashop.on('opc-app-init', (params) => { 34 const { JqueryElementMain } = params; 35 }); 36 37 //Login - Events 38 prestashop.on('opc-login-loginCustomer-error', (params) => { 39 const { JqueryElement } = params; 40 41 //idxrdefender - v1.3.2 - innovadeluxe 42 if (typeof IdxrdefenderFront !== typeof undefined) { 43 JqueryElement.find('#g-recaptcha-response-login').val(''); 44 let defender = new IdxrdefenderFront(); 45 defender.bindsCaptcha(); 46 } 47 }); 48 49 //Personal Information - Events 50 prestashop.on('opc-personal_information-saveCustomer-error', (params) => { 51 const { JqueryElement } = params; 52 53 //idxrdefender - v1.3.2 - innovadeluxe 54 if (typeof IdxrdefenderFront !== typeof undefined) { 55 JqueryElement.find('#g-recaptcha-response-login').val(''); 56 let defender = new IdxrdefenderFront(); 57 defender.bindsCaptcha(); 58 } 59 }); 60 61 //Addresses - Events 62 prestashop.on('opc-addresses-getAddresses-complete', (params) => { 63 const { JqueryElement } = params; 64 }); 65 prestashop.on('opc-addresses-getAddresses-complete-edit', (params) => { 66 const { JqueryElement } = params; 67 68 //facturare - v4.1.5 - Daniel Patilea 69 if (typeof initListen !== typeof undefined) { 70 initListen(); 71 } 72 }); 73 prestashop.on('opc-addresses-getAddresses-complete-add', (params) => { 74 const { JqueryElement } = params; 75 76 //facturare - v4.1.5 - Daniel Patilea 77 if (typeof initListen !== typeof undefined) { 78 initListen(); 79 } 80 }); 81 82 //Shipping - Events 83 prestashop.on('opc-shipping-getCarrierList-complete', (params) => { 84 const { JqueryElement, JqueryElementContent } = params; 85 86 //support module: mondialrelay - v3.3.3 - ScaleDEV 87 //se hizo modificacion a medida en dicho modulo para poder funcionar. 88 if (typeof window.mondialrelayWidget !== typeof undefined) { 89 if (typeof MONDIALRELAY_SELECTED_RELAY_IDENTIFIER !== typeof undefined) { 90 window.mondialrelayWidget.savedRelay = MONDIALRELAY_SELECTED_RELAY_IDENTIFIER; 91 } 92 93 $(window.mondialrelayWidget).trigger('mondialrelay.ready'); 94 95 // if (typeof window.mondialrelayWidget !== typeof undefined) { 96 // $(document).off('click', window.mondialrelayWidget.save_button); 97 // } 98 99 // let _script = document.createElement('script'); 100 // _script.type = 'text/javascript'; 101 // _script.src = prestashop.urls.base_url + 'modules/mondialrelay/views/js/front/checkout/checkout-17.js'; 102 // JqueryElementContent.append(_script); 103 104 // if (typeof window.mondialrelayWidget !== typeof undefined) { 105 // if (typeof MONDIALRELAY_SELECTED_RELAY_IDENTIFIER !== typeof undefined) { 106 // window.mondialrelayWidget.savedRelay = MONDIALRELAY_SELECTED_RELAY_IDENTIFIER; 107 // } 108 109 // $(window.mondialrelayWidget).trigger('mondialrelay.ready'); 110 // } 111 } 112 113 //swastarkencl - v3.6.0 - Softwareagil 114 if (typeof swastarkenclRunOnReady !== typeof undefined) { 115 swastarkenclRunOnReady(); 116 } 117 118 //gmparcellocker - v1.4.1 - GreenMouseStudio.com 119 if (typeof gmParcelLockerAjaxUrl !== typeof undefined && JqueryElement.find('#easypack-widget').length > 0) { 120 window.easyPack.dropdownWidget('easypack-widget', function (point) { 121 const pointData = point.name + '| ' + point.address.line1 + '| ' + point.address.line2; 122 $.ajax({
123 url: gmParcelLockerAjaxUrl, 124 type: 'POST', 125 crossDomain: true, 126 data: {cartId: gmCartId, pointData: pointData}, 127 async: true, 128 dataType: "json", 129 headers: {"cache-control": "no-cache"}, 130 success: function (data) { 131 if (data.msg == 'OK') { 132 $('.chosen-parcel').html(pointData.split('|').join(',')); 133 134 if (typeof window.checkGmParcellocker !== typeof undefined) { 135 window.gmparcellockerCheckStoreSelected(JqueryElement); 136 } 137 } 138 }, 139 error: function (jqXHR, textStatus) { 140 console.log(jqXHR.responseText); 141 } 142 }); 143 }); 144 145 window.gmparcellockerCheckStoreSelected = function(JqueryElement) { 146 if (JqueryElement.find('.gmparcellocker-button').is(':visible')) { 147 window.checkGmParcellocker = true; 148 if (JqueryElement.find('.chosen-parcel').text().length > 3) { 149 window.gmparcellockerStoreSelected = true; 150 } else { 151 window.gmparcellockerStoreSelected = false; 152 } 153 } else { 154 if (window.checkGmParcellocker) { 155 window.gmparcellockerStoreSelected = true; 156 window.checkGmParcellocker = false; 157 } 158 } 159 } 160 161 const gmparcellocker = window.setInterval(function () { 162 if (typeof window.checkGmParcellocker !== typeof undefined) { 163 window.gmparcellockerCheckStoreSelected(JqueryElement); 164 165 clearInterval(gmparcellocker); 166 } 167 }, 500); 168 } 169 170 //support module: sendcloud - v1.5.2 - Sendcloud 171 const scriptSendCloud = $('script[src^="https://servicepoints.sendcloud.sc/shops/prestashop/"]').attr('src'); 172 if (typeof scriptSendCloud !== typeof undefined) { 173 let _script = document.createElement('script'); 174 _script.type = 'text/javascript'; 175 _script.src = scriptSendCloud; 176 JqueryElementContent.append(_script); 177 } 178 }); 179 180 //Payment - Events 181 prestashop.on('opc-payment-getPaymentList-complete', (params) => { 182 const { JqueryElement } = params; 183 184 let paymentList = []; 185 JqueryElement.find('.payment_radio').each(function (i, item) { 186 paymentList.push($(item).val()); 187 }); 188 189 //ps_checkout - v2.15.4 - PrestaShop 190 if (typeof window.ps_checkout !== typeof undefined && typeof JqueryElement !== typeof undefined) { 191 window.ps_checkout.events = new EventTarget(); 192 window.ps_checkout.events.addEventListener('payment-option-active', ({ detail }) => { 193 const { HTMLElementContainer } = detail; 194 $(HTMLElementContainer).parent().show(); 195 }); 196 197 JqueryElement.find('.payment_radio').each(function (i, item) { 198 const $item = $(item); 199 const moduleName = $item.data('module-name'); 200 const $container = $item.parents('#' + $item.prop('id') + '-container'); 201 202 if (-1 !== moduleName.search('ps_checkout')) { 203 $container.parent().hide(); 204 } 205 }); 206 207 window.ps_checkout.renderCheckout(); 208 } 209 210 //paytpv - v7.7.1 - Paycomet 211 if (typeof paytpv_initialize !== typeof undefined) { 212 paytpv_initialize(); 213 } 214 215 //pts_stripe - v4.0.6 - PresTeamShop 216 if (typeof AppPTSS !== typeof undefined) { 217 AppPTSS.setup(); 218 } 219 220 //klarnapaymentsofficial - v2.2.3 - Prestaworks AB 221 if (paymentList.includes("klarnapaymentsofficial")/*typeof kp_client_token !== typeof undefined*/) {
222 const klarna_options = $('.klarna-container'); 223 224 for (const element of klarna_options) { 225 const payment_category = element.id.substring(26, element.id.length); 226 $('input[data-module-name=klarnapayments_' + payment_category + '_module]') 227 .click(function () { 228 initiateKlarnaWidget(kp_client_token, '#' + element.id, payment_category); 229 }) 230 .parents('.module_payment_container').click(function () { 231 initiateKlarnaWidget(kp_client_token, '#' + element.id, payment_category); 232 }); 233 } 234 235 $('#payment-confirmation > .ps-shown-by-js button').click(function(event) { 236 for (const element of klarna_options) { 237 const payment_category = element.id.substring(26, element.id.length); 238 if ($('input[data-module-name=klarnapayments_' + payment_category + '_module]').is(':checked')) { 239 event.preventDefault(); 240 setupKlarnaAuthCall(payment_category); 241 return; 242 } 243 } 244 }); 245 } 246 247 if (typeof prestashop !== typeof undefined && typeof prestashop.emit !== typeof undefined) { 248 prestashop.emit('steco_event_updated'); 249 } 250 251 //stripejs - v4.3.9 - NTS 252 if (paymentList.includes("stripejs") && typeof stripe_allow_cards !== typeof undefined && typeof StripePubKey !== typeof undefined) { 253 let _script = document.createElement('script'); 254 _script.type = 'text/javascript'; 255 _script.src = prestashop.urls.base_url + 'modules/stripejs/views/js/stripe-prestashop.js'; 256 JqueryElement.append(_script); 257 } 258 259 //kf_paypal - v2.1.7 - KForge 260 if (paymentList.includes("kfpaypal")) { 261 let _script = document.createElement('script'); 262 _script.type = 'text/javascript'; 263 _script.src = prestashop.urls.base_url + 'modules/kf_paypal/views/js/front.js'; 264 JqueryElement.append(_script); 265 } 266 267 //mollie - v5.0.1 - Mollie B.V. 268 if (paymentList.includes("mollie")) { 269 let $mollieContainers = JqueryElement.find('.mollie-iframe-container'); 270 if ($mollieContainers.length) { 271 let _script = document.createElement('script'); 272 _script.type = 'text/javascript'; 273 _script.src = prestashop.urls.base_url + 'modules/mollie/views/js/front/mollie_iframe.js'; 274 JqueryElement.append(_script); 275 } 276 } 277 278 //hipay_enterprise - v2.17.0 - HiPay 279 if (typeof initEventsHostedFields !== typeof undefined && typeof initHostedFields !== typeof undefined) { 280 initEventsHostedFields(); 281 initHostedFields(); 282 } 283 284 //a4pauthorizenet - v2.0.1 - Addons4Presta 285 if (paymentList.includes("a4pauthorizenet")) { 286 let _script = document.createElement('script'); 287 _script.type = 'text/javascript'; 288 _script.src = prestashop.urls.base_url + '/modules/a4pauthorizenet/views/js/a4pauthorizenet.js'; 289 JqueryElement.append(_script); 290 } 291 292 //braintreejs - v3.1.2 - Bellini Services 293 if (paymentList.includes("braintreejs")) { 294 if (typeof braintreeHostedSetup !== typeof undefined) { 295 braintreeHostedSetup(); 296 } else if (typeof braintreePaypalSetup !== typeof undefined) { 297 braintreePaypalSetup(); 298 } else if (typeof braintreeSetup !== typeof undefined) { 299 braintreeSetup(); 300 } 301 } 302 303 //support braintreeofficial: v1.2.5 - 202 ecommerce 304 if (typeof BraintreeSubmitPayment !== typeof undefined) { 305 var _script = document.createElement('script'); 306 _script.type = 'text/javascript'; 307 _script.src = prestashop.urls.base_url + 'modules/braintreeofficial/views/js/payment_bt.js';
308 JqueryElement.append(_script); 309 } else if (typeof BraintreePaypalSubmitPayment !== typeof undefined) { 310 var _script = document.createElement('script'); 311 _script.type = 'text/javascript'; 312 _script.src = prestashop.urls.base_url + 'modules/braintreeofficial/views/js/payment_pbt.js'; 313 JqueryElement.append(_script); 314 } 315 316 //support paypalplus: v1.2.3 - PixelWeb 317 if (paymentList.includes("paypalplus") && typeof paypalplus !== typeof undefined) { 318 $(document).ready(_paypalplus.ready); 319 } 320 321 //revolutpayment - v2.2.4 - Revolut 322 if (paymentList.includes("revolutpayment")) { 323 let _script = document.createElement('script'); 324 _script.type = 'text/javascript'; 325 _script.src = prestashop.urls.base_url + '/modules/revolutpayment/views/js/version17/revolut.payment.js'; 326 JqueryElement.append(_script); 327 } 328 329 //smallpay - v4.0.0 - SmallPay Srl 330 if (paymentList.includes("smallpay")) { 331 let _script = document.createElement('script'); 332 _script.type = 'text/javascript'; 333 _script.src = prestashop.urls.base_url + '/modules/smallpay/views/js/front.js'; 334 JqueryElement.append(_script); 335 } 336 337 //payoutloud - v1.2.2 - AdsOutLoud LLC 338 if (paymentList.includes("Google Pay") && paymentList.includes("Apple Pay")) { 339 let _script = document.createElement('script'); 340 _script.type = 'text/javascript'; 341 _script.src = prestashop.urls.base_url + '/modules/payoutloud/views/js/payment_request.js'; 342 JqueryElement.append(_script); 343 } 344 }); 345 346 prestashop.on('opc-payment-toggleOrderButton-after', (params) => { 347 const { JqueryElement, selectedOption, confirmationSelector, showConfirmationSelector } = params; 348 349 //ps_checkout - v2.15.4 - PrestaShop 350 if (typeof window.ps_checkout !== typeof undefined && typeof JqueryElement !== typeof undefined) { 351 JqueryElement.find('.js-payment-binary #btn-placer_order').show(); 352 } 353 354 //paypal - v5.4.7 - 202 ecommerce 355 if (typeof JqueryElement !== typeof undefined && typeof confirmationSelector !== typeof undefined) { 356 if (JqueryElement.find('input[name="payment-option"]:checked').attr("data-module-name") === 'paypal') { 357 const paypalEcWrongButtonMessage = JqueryElement.find('[paypal-ec-wrong-button-message]'); 358 if (paypalEcWrongButtonMessage.length > 0) { 359 JqueryElement.find(confirmationSelector + ' button').on('click', function (event) { 360 event.preventDefault(); 361 event.stopPropagation(); 362 paypalEcWrongButtonMessage.show(); 363 }); 364 } 365 } 366 } 367 368 //ets_payment_with_fee - v2.2.9 - ETS-Soft. 369 if (typeof ets_cookie_module_name !== typeof undefined) { 370 ets_cookie_payment_option = false; 371 ajaxChangePaymentMethod = function (){}; 372 373 if (typeof ajaxChangePaymentMethodOPC !== typeof undefined) { 374 ajaxChangePaymentMethodOPC(params); 375 } else { 376 ajaxChangePaymentMethodOPC = function(params) { 377 const { JqueryElement, selectedOption } = params; 378 379 if (typeof selectedOption !== typeof undefined) { 380 const $paymentSelected = JqueryElement.find('input[name="payment-option"]:checked'); 381 const moduleName = $paymentSelected.data('module-name'); 382 let paymentMethodId = 0; 383 384 if (JqueryElement.find('#pay-with-' + selectedOption + '-form input[name="id_payment_method"]').length > 0) { 385 paymentMethodId = JqueryElement.find('#pay-with-' + selectedOption + '-form input[name="id_payment_method"]').val(); 386 } 387 388 $.ajax({
389 url: '', 390 data: 'ets_set_payment_option=1&module_name=' + moduleName + '&id_payment_method=' + paymentMethodId + '&payment_option=' + selectedOption, 391 type: 'post', 392 dataType: 'json', 393 beforeSend: function () { 394 JqueryElement.append($('<div class="loading-opc"/>')); 395 }, 396 complete: function () { 397 JqueryElement.find('.loading-opc').remove(); 398 } 399 }); 400 } 401 }; 402 403 ajaxChangePaymentMethodOPC(params); 404 } 405 } 406 407 //hipay_enterprise - v2.17.0 - HiPay 408 if (typeof setSelectedPaymentMethod !== typeof undefined) { 409 setSelectedPaymentMethod(); 410 } 411 412 //revolutpayment - v2.2.4 - Revolut 413 if (typeof JqueryElement.find('input#' + selectedOption) !== typeof undefined) { 414 if (JqueryElement.find('input#' + selectedOption).data('module-name') === 'Revolut Pay - Get Cashback') { 415 JqueryElement.find(confirmationSelector + ' button').addClass('revolut_hide'); 416 } else if (showConfirmationSelector) { 417 JqueryElement.find(confirmationSelector + ' button').removeClass('revolut_hide'); 418 } 419 } 420 }); 421 422 prestashop.on('opc-payment-toggleOrderButton-validation', (params) => { 423 const { JqueryElementMain, JqueryElement, JqueryElementShipping, confirmationAlertSelector } = params; 424 425 const extraContentCarrierSelected = JqueryElementShipping.find('.delivery_option_radio:checked').parents('.delivery-option').next(); 426 427 //Reset 428 if (intervalPaymentToggleOrderButtonValidation !== null) { 429 clearInterval(intervalPaymentToggleOrderButtonValidation); 430 } 431 JqueryElement.data('opc-payment-toggleOrderButton-validation', true); 432 433 //glsshipping - v3.3.2 - GLS 434 if (JqueryElementShipping.find('#parcelshopid').length > 0) { 435 const parcelShopId = parseInt(JqueryElementShipping.find('#parcelshopid').val()); 436 const deliveryIdSelected = parseInt(JqueryElementShipping.find('.delivery_option_radio:checked').val()); 437 438 if (parcelShopId === deliveryIdSelected && JqueryElementShipping.find('#parcel_codigo').val() === '') { 439 JqueryElement.data('opc-payment-toggleOrderButton-validation', false); 440 441 $(confirmationAlertSelector).text(OPC.Message.pickupStoreRequired); 442 443 intervalPaymentToggleOrderButtonValidation = setInterval(function () { 444 if (JqueryElementShipping.find('#parcel_codigo').val() !== '') { 445 JqueryElement.find('input[name="payment-option"]:checked').trigger('click'); 446 447 clearInterval(intervalPaymentToggleOrderButtonValidation); 448 } 449 }, 1000); 450 } else { 451 JqueryElement.data('opc-payment-toggleOrderButton-validation', true); 452 } 453 } 454 455 //gmparcellocker - v1.4.1 - GreenMouseStudio.com 456 if (typeof window.gmparcellockerStoreSelected !== typeof undefined) { 457 if (!window.gmparcellockerStoreSelected) { 458 JqueryElement.data('opc-payment-toggleOrderButton-validation', false); 459 460 $(confirmationAlertSelector).text(OPC.Message.pickupStoreRequired); 461 462 intervalPaymentToggleOrderButtonValidation = setInterval(function () { 463 if (window.gmparcellockerStoreSelected) { 464 JqueryElement.find('input[name="payment-option"]:checked').trigger('click'); 465 466 clearInterval(intervalPaymentToggleOrderButtonValidation); 467 } 468 }, 1000); 469 } else { 470 JqueryElement.data('opc-payment-toggleOrderButton-validation', true); 471 } 472 } 473 474 //samedaycourier - v1.4.22 - Sameday Courier 475 if (typeof extraContentCarrierSelected.find('#locker_name').val() !== typeof undefined) { 476 if (extraContentCarrierSelected.find('#locker_name').val() === '') { 477 JqueryElement.data('opc-payment-toggleOrderButton-validation', false); 478 479 $(confirmationAlertSelector).text(OPC.Message.pickupStoreRequired); 480 481 intervalPaymentToggleOrderButtonValidation = setInterval(function () { 482 if (extraContentCarrierSelected.find('#locker_name').val() !== '') { 483 JqueryElement.find('input[name="payment-option"]:checked').trigger('click'); 484 485 clearInterval(intervalPaymentToggleOrderButtonValidation); 486 } 487 }, 1000); 488 } else { 489 JqueryElement.data('opc-payment-toggleOrderButton-validation', true); 490 } 491 } 492 });
493 494 prestashop.on('opc-cart-getCartSummary-complete', (params) => { 495 const { JqueryElement } = params; 496 }); 497}
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.