/* COSTARICA
// Eliminar cupones de BOGO o otras promos de checkout
removeOldPromosCheckout()
* Custom code goes here.
* A template should always ship with an empty custom.js
*/
//var cities = ['San José', 'Heredia', 'Alajuela', 'Cartago', 'Puntarenas','Limón', 'Guanacanaste'];
var provinces = JSON.parse(
'{"San Jose":{"San José":["Carmen","Merced","Hospital","Catedral","Zapote","San Francisco de Dos Ríos","Uruca","Mata Redonda","Pavas","Hatillo","San Sebastián"],"Escazú":["Escazú","San Antonio","San Rafael"],"Desamparados":["Desamparados","San Miguel","San Juan de Dios","San Rafael Arriba","San Antonio","Frailes","Patarrá","San Cristóbal","Rosario","Damas","San Rafael Abajo","Gravilias","Los Guido"],"Puriscal":["Santiago","Mercedes Sur","Barbacoas","Grifo Alto","San Rafael","Candelarita","Desamparaditos","San Antonio","Chires"],"Tarrazú":["San Marcos","San Lorenzo","San Carlos"],"Aserrí":["Aserrí","Tarbaca","Vuelta de Jorco","San Gabriel","Legua","Monterrey","Salitrillos"],"Mora":["Colón","Guayabo","Tabarcia","Piedras Negras","Picagres","Jaris","Quitirrisí"],"Goicoechea":["Guadalupe","San Francisco","Calle Blancos","Mata de Plátano","Ipís","Rancho Redondo","Purral"],"Santa Ana":["Santa Ana","Salitral","Pozos","Uruca","Piedades","Brasil"],"Alajuelita":["Alajuelita","San Josecito","San Antonio","Concepción","San Felipe"],"Vásquez de Coronado":["San Isidro","San Rafael","Dulce Nombre de Jesús","Patalillo","Cascajal"],"Acosta":["San Ignacio","Guaitil","Palmichal","Cangrejal","Sabanillas"],"Tibás":["San Juan","Cinco Esquinas","Anselmo Llorente","León XIII","Colima"],"Moravia":["San Vicente","San Jerónimo","La Trinidad"],"Montes de Oca":["San Pedro","Sabanilla","Mercedes","San Rafael"],"Turrubares":["San Pablo","San Pedro","San Juan de Mata","San Luis","Carara"],"Dota":["Santa María","Jardín","Copey"],"Curridabat":["Curridabat","Granadilla","Sánchez","Tirrases"],"Pérez Zeledón":["San Isidro de El General","El General","Daniel Flores","Rivas","San Pedro","Platanares","Pejibaye","Cajón","Barú","Río Nuevo","Páramo","La Amistad"],"León Cortés Castro":["San Pablo","San Andrés","Llano Bonito","San Isidro","Santa Cruz","San Antonio"]},"Alajuela":{"Alajuela":["Alajuela","San José","Carrizal","San Antonio","Guácima","San Isidro","Sabanilla","San Rafael","Río Segundo","Desamparados","Turrúcares","Tambor","Garita","Sarapiquí"],"San Ramón":["San Ramón","Santiago","San Juan","Piedades Norte","Piedades Sur","San Rafael","San Isidro","Los Ángeles","Alfaro","Volio","Concepción","Zapotal","Peñas Blancas","San Lorenzo"],"Grecia":["Grecia","San Isidro","San José","San Roque","Tacares","Río Cuarto","Puente de Piedra","Bolívar"],"San Mateo":["San Mateo","Desmonte","Jesús María","Labrador"],"Atenas":["Atenas","Jesús","Mercedes","San Isidro","Concepción","San José","Santa Eulalia","Escobal"],"Naranjo":["Naranjo","San Miguel","San José","Cirrí Sur","San Jerónimo","San Juan","El Rosario","Palmitos"],"Palmares":["Palmares","Zaragoza","Buenos Aires","Santiago","Candelaria","Esquipulas","La Granja"],"Poás":["San Pedro","San Juan","San Rafael","Carrillos","Sabana Redonda"],"Orotina":["Orotina","El Mastate","Hacienda Vieja","Coyolar","La Ceiba"],"San Carlos":["Quesada","Florencia","Buenavista","Aguas Zarcas","Venecia","Pital","La Fortuna","La Tigra","La Palmera","Venado","Cutris","Monterrey","Pocosol"],"Zarcero":["Zarcero","Laguna","Tapezco","Guadalupe","Palmira","Zapote","Brisas"],"Valverde Vega":["Sarchí Norte","Sarchí Sur","Toro Amarillo","San Pedro","Rodríguez"],"Upala":["Upala","Aguas Claras","San José o Pizote","Bijagua","Delicias","Dos Ríos","Yolillal","Canalete"],"Los Chiles":["Los Chiles","Caño Negro","El Amparo","San Jorge"],"Guatuso":["San Rafael","Buenavista","Cote","Katira"],"Río Cuarto":["Río Cuarto"]},"Cartago":{"Cartago":["Oriental","Occidental","Carmen","San Nicolás","Aguacaliente o San Francisco","Guadalupe o Arenilla","Corralillo","Tierra Blanca","Dulce Nombre","Llano Grande","Quebradilla"],"Paraíso":["Paraíso","Santiago","Orosi","Cachí","Llanos de Santa Lucía"],"La Unión":["Tres Ríos","San Diego","San Juan","San Rafael","Concepción","Dulce Nombre","San Ramón","Río Azul"],"Jiménez":["Juan Viñas","Tucurrique","Pejibaye"],"Turrialba":["Turrialba","La Suiza","Peralta","Santa Cruz","Santa Teresita","Pavones","Tuis","Tayutic","Santa Rosa","Tres Equis","La Isabel","Chirripó"],"Alvarado":["Pacayas","Cervantes","Capellades"],"Oreamuno":["San Rafael","Cot","Potrero Cerrado","Cipreses","Santa Rosa"],"El Guarco":["Tejar","San Isidro","Tobosi","Patio de Agua"]},"Heredia":{"Heredia":["Heredia","Mercedes","San Francisco","Ulloa","Varablanca"],"Barva":["Barva","San Pedro","San Pablo","San Roque","Santa Lucía","San José de la Montaña"],"Santo Domingo":["Santo Domingo","San Vicente","San Miguel","Paracito","Santo Tomás","Santa Rosa","Tures","Para"],"Santa Bárbara":["Santa Bárbara","San Pedro","San Juan","Jesús","Santo Domingo","Puraba"],"San Rafael":["San Rafael","San Josécito","Santiago","Ángeles","Concepción"],"San Isidro":["San Isidro","San José","Concepción","San Francisco"],"Belén":["San Antonio","La Ribera","La Asunción"],"Flores":["San Joaquín","Barrantes","Llorente"],"San Pablo":["San Pablo","Rincón de Sabanilla"],"Sarapiquí":["Puerto Viejo","La Virgen","Horquetas","Llanuras del Gaspar","Cureña"]},"Guanacaste":{"Liberia":["Liberia","Cañas Dulces","Mayorga","Nacascolo","Curubandé"],"Nicoya":["Nicoya","Mansion","San Antonio","Quebrada Honda","Samara","Nosara","Belén de Nosarita"],"Santa Cruz":["Santa Cruz","Bolsón","Veintisiete de Abril","Tempate","Cartagena","Cuajiniquil","Diria","Cabo Velas","Tamarindo"],"Bagaces":["Bagaces","Fortuna","Mogote","Río Naranjo"],"Carrillo":["Filadelfia","Palmira","Sardinal","Belén"],"Cañas":["Cañas","Palmira","San Miguel","Bebedero","Porozal"],"Abangares":["Juntas","Sierra","San Juan","Colorado"],"Tilarán":["Tilarán","Quebrada Grande","Tronadora","Santa Rosa","Líbano","Tierras Morenas","Arenal"],"Nandayure":["Carmona","Santa Rita","Zapotal","San Pablo","Porvenir","Bejuco"],"La Cruz":["La Cruz","Santa Cecilia","Garita","Santa Elena"],"Hojancha":["Hojancha","Monte Romo","Puerto Carrillo","Huacas"]},"Puntarenas":{"Puntarenas":["Puntarenas","Pitahaya","Chomes","Lepanto","Paquera","Manzanillo","Guacimal","Barranca","Monte Verde","Isla del Coco","Cobano","Chacarita","Chira","Acapulco","El Roble","Arancibia"],"Esparza":["Espiritu Santo","San Juan Grande","Macacona","San Rafael","San Jerónimo","Caldera"],"Buenos Aires":["Buenos Aires","Volcan","Potrero Grande","Boruca","Pilas","Colinas","Changena","Briolley","Brunka"],"Montes de Oro":["Miramar","La Unión","San Isidro"],"Osa":["Puerto Cortés","Palmar","Sierpe","Bahia Ballena","Piedras Blancas","Bahía Drake"],"Quepos":["Quepos","Savegre","Naranjito"],"Golfito":["Golfito","Puerto Jiménez","Guaycará","Pavón"],"Coto Brus":["San Vito","Sabalito","Aguabuena","Limóncito","Pittier","Gutiérrez Braun"],"Parrita":["Parrita"],"Corredores":["Corredor","La Cuesta","Canoas","Laurel"],"Garabito":["Jacó","Tarcoles"]},"Limon":{"Limón":["Limón","Valle La Estrella","Río Blanco","Matama"],"Pococí":["Guapiles","Jiménez","La Rita","Roxana","Cariari","Colorado","La Colonia"],"Siquirres":["Siquirres","Pacuarito","Florida","Germania","Cairo","Alegría"],"Talamanca":["Bratsi","Sixaola","Cahuita","Telire"],"Matina":["Matina","Batán","Carrandi"],"Guácimo":["Guácimo","Mercedes","Pocora","Río Jiménez","Duacarí"]}}'
);
var provin = "12";
var cantono = "12";
var provin1 = "12";
var cantono1 = "12";
var provinp = "12";
var cantonop = "12";
var provin1p = "12";
var cantono1p = "12";
var initial_cant = "12";
var initial_distr = "12";
var initial_cantp = "12";
var initial_distrp = "12";
var page_set = "none";
if ($('select[name="id_state"]').length > 0) {
page_set = "order";
}
if ($('select[name="shipping_address[id_state]"]').length > 0) {
page_set = "supercheckout";
}
if (page_set != "none") {
$(document).ready(function () {
if (page_set == "order") {
initial_cant = $('input[name="canton"]').val();
initial_distr = $('input[name="district"]').val();
var canton_div = $('input[name="canton"]').parent();
$('input[name="canton"]').hide();
$(canton_div).append(
''
);
$(document).on("change", 'select[name="id_state"]', function (e) {
provin = $('select[name="id_state"] option:selected').html();
$("#canton_new").html("");
$.each(provinces[provin], function (key, value) {
var option =
"";
$("#canton_new").append(option);
});
$("#canton_new").trigger("change");
});
$(document).on("change", "#canton_new", function (e) {
var val = $("#canton_new option:selected").html();
$('input[name="canton"]').val($("#canton_new").val());
});
var district_div = $('input[name="district"]').parent();
$('input[name="district"]').hide();
$(district_div).append(
''
);
$(document).on("change", "#canton_new", function (e) {
cantono = $("#canton_new option:selected").html();
$("#district_new").html("");
$.each(provinces[provin][cantono], function (key, value) {
var option = "";
$("#district_new").append(option);
});
$("#district_new").trigger("change");
});
$(document).on("change", "#district_new", function (e) {
var val = $("#district_new option:selected").html();
$('input[name="district"]').val($("#district_new").val());
});
// setDefaultsForPaymentDetailsSection();
//setDefaultsForUnsignedDetailsSection();
setTimeout(function () {
$('select[name="id_state"]').trigger("change");
}, 100);
setTimeout(function () {
$("#canton_new").val(initial_cant);
$("#canton_new").trigger("change");
}, 200);
setTimeout(function () {
$("#district_new").val(initial_distr);
// $('#district_new').trigger('change');
}, 300);
}
/*
var city_div = $('input[name="city"]').parent();
$('input[name="city"]').hide();
$(city_div).append('');
$.each(cities, function(key, value) {
var option = "";
$('#city_new').append(option);
console.log(value);
});
$(document).on('change', '#city_new', function(e){
var val = $('#city_new option:selected').html();
var a = cities.indexOf(val);
$('input[name="city"]').val($('#city_new').val());
console.log(val);
});
$('#city_new').trigger('change');
*/
if (page_set == "supercheckout") {
initial_cant = $(
'.shipping_update_form input[name="shipping_update_canton_holder"]'
).val();
initial_distr = $(
'.shipping_update_form input[name="shipping_update_district_holder"]'
).val();
initial_cant = $(
'.payment_update_form input[name="payment_update_canton_holder"]'
).val();
initial_distr = $(
'.payment_update_form input[name="payment_update_district_holder"]'
).val();
// loadDeafultsP();
$(document).on(
"change",
'#shipping-new select[name="shipping_address[id_state]"]',
function (e) {
provin = $(this).find("option:selected").html();
$('#shipping-new select[name="shipping_new_canton"]').html("");
if (provinces[provin] != undefined) {
$.each(provinces[provin], function (key, value) {
var option =
"";
$('#shipping-new select[name="shipping_new_canton"]').append(
option
);
});
}
$('#shipping-new select[name="shipping_new_canton"]').trigger(
"change"
);
}
);
$(document).on(
"change",
'#payment-new select[name="payment_address[id_state]"]',
function (e) {
provinp = $(this).find("option:selected").html();
$('#payment-new select[name="payment_new_canton"]').html("");
if (provinces[provinp] != undefined) {
$.each(provinces[provinp], function (key, value) {
var option =
"";
$('#payment-new select[name="payment_new_canton"]').append(
option
);
});
}
$('#payment-new select[name="payment_new_canton"]').trigger("change");
}
);
$(document).on(
"change",
'.shipping_update_form select[name="shipping_address[id_state]"]',
function (e) {
provin1 = $(this).find("option:selected").html();
$('.shipping_update_form select[name="shipping_update_canton"]').html(
""
);
if (provinces[provin1] != undefined) {
$.each(provinces[provin1], function (key, value) {
var option =
"";
$(
'.shipping_update_form select[name="shipping_update_canton"]'
).append(option);
});
}
$(
'.shipping_update_form select[name="shipping_update_canton"]'
).trigger("change");
}
);
$(document).on(
"change",
'.payment_update_form select[name="payment_address[id_state]"]',
function (e) {
provin1p = $(this).find("option:selected").html();
$('.payment_update_form select[name="payment_update_canton"]').html(
""
);
if (provinces[provin1p] != undefined) {
$.each(provinces[provin1p], function (key, value) {
var option =
"";
$(
'.payment_update_form select[name="payment_update_canton"]'
).append(option);
});
}
$(
'.payment_update_form select[name="payment_update_canton"]'
).trigger("change");
}
);
//DIstricts
$(document).on(
"change",
'#shipping-new select[name="shipping_new_canton"]',
function (e) {
cantono = $(this).find("option:selected").html();
$('#shipping-new select[name="shipping_new_district"]').html("");
if (provinces[provin][cantono] != undefined) {
$.each(provinces[provin][cantono], function (key, value) {
var option =
"";
$('#shipping-new select[name="shipping_new_district"]').append(
option
);
});
}
$('#shipping-new select[name="shipping_new_district"]').trigger(
"change"
);
$("#shipping_address_canton").val(
$('#shipping-new select[name="shipping_new_canton"]').val()
);
}
);
$(document).on(
"change",
'#payment-new select[name="payment_new_canton"]',
function (e) {
cantonop = $(this).find("option:selected").html();
$('#payment-new select[name="payment_new_district"]').html("");
if (provinces[provinp][cantonop] != undefined) {
$.each(provinces[provinp][cantonop], function (key, value) {
var option =
"";
$('#payment-new select[name="payment_new_district"]').append(
option
);
});
}
$('#payment-new select[name="payment_new_district"]').trigger(
"change"
);
$("#payment_address_canton").val(
$('#payment-new select[name="payment_new_canton"]').val()
);
}
);
$(document).on(
"change",
'.shipping_update_form select[name="shipping_update_canton"]',
function (e) {
cantono1 = $(this).find("option:selected").html();
$(
'.shipping_update_form select[name="shipping_update_district"]'
).html("");
if (provinces[provin1][cantono1] != undefined) {
$.each(provinces[provin1][cantono1], function (key, value) {
var option =
"";
$(
'.shipping_update_form select[name="shipping_update_district"]'
).append(option);
});
}
$(
'.shipping_update_form select[name="shipping_update_district"]'
).trigger("change");
$("#shipping_address_canton").val(
$(
'.shipping_update_form select[name="shipping_update_canton"]'
).val()
);
}
);
$(document).on(
"change",
'.payment_update_form select[name="payment_update_canton"]',
function (e) {
cantono1p = $(this).find("option:selected").html();
$('.payment_update_form select[name="payment_update_district"]').html(
""
);
if (provinces[provin1p][cantono1p] != undefined) {
$.each(provinces[provin1p][cantono1p], function (key, value) {
var option =
"";
$(
'.payment_update_form select[name="payment_update_district"]'
).append(option);
});
}
$(
'.payment_update_form select[name="payment_update_district"]'
).trigger("change");
$("#payment_address_canton").val(
$('.payment_update_form select[name="payment_update_canton"]').val()
);
}
);
$(document).on(
"change",
'#shipping-new select[name="shipping_new_district"]',
function (e) {
$("#shipping_address_district").val(
$('#shipping-new select[name="shipping_new_district"]').val()
);
}
);
$(document).on(
"change",
'#payment-new select[name="payment_new_district"]',
function (e) {
$("#payment_address_district").val(
$('#payment-new select[name="payment_new_district"]').val()
);
}
);
$(document).on(
"change",
'.shipping_update_form select[name="shipping_update_district"]',
function (e) {
$("#shipping_address_district").val(
$(
'.shipping_update_form select[name="shipping_update_district"]'
).val()
);
}
);
$(document).on(
"change",
'.payment_update_form select[name="payment_update_district"]',
function (e) {
$("#payment_address_district").val(
$(
'.payment_update_form select[name="payment_update_district"]'
).val()
);
}
);
}
});
}
$(function () {
payment_form = $("form").attr("id");
addLinkToSetDefaults();
});
function loadDeafultsP() {
provin = $('#shipping-new select[name="shipping_address[id_state]"]')
.find("option:selected")
.html();
provinp = $('#payment-new select[name="payment_address[id_state]"]')
.find("option:selected")
.html();
provin1 = $('.shipping_update_form select[name="shipping_address[id_state]"]')
.find("option:selected")
.html();
provin1p = $('.payment_update_form select[name="payment_address[id_state]"]')
.find("option:selected")
.html();
if (provinces[provin] != "undefined") {
$.each(provinces[provin], function (key, value) {
var option =
"";
$('#shipping-new select[name="shipping_new_canton"]').append(option);
});
}
if (provinces[provinp] != "undefined") {
$.each(provinces[provinp], function (key, value) {
var option =
"";
$('#payment-new select[name="payment_new_canton"]').append(option);
});
}
if (provinces[provin1] != "undefined") {
$.each(provinces[provin1], function (key, value) {
var option =
"";
$('.shipping_update_form select[name="shipping_update_canton"]').append(
option
);
});
}
if (provinces[provin1p] != "undefined") {
$.each(provinces[provin1p], function (key, value) {
var option =
"";
$('.payment_update_form select[name="payment_update_canton"]').append(
option
);
});
}
$('.shipping_update_form select[name="shipping_update_canton"]').val(
'.shipping_update_form select[name="shipping_update_canton_holder"]'
);
$('.payment_update_form select[name="payment_update_canton"]').val(
'.payment_update_form select[name="payment_update_canton_holder"]'
);
cantono = $('#shipping-new select[name="shipping_new_canton"]')
.find("option:selected")
.html();
cantonop = $('#payment-new select[name="payment_new_canton"]')
.find("option:selected")
.html();
cantono1 = $('.shipping_update_form select[name="shipping_update_canton"]')
.find("option:selected")
.html();
cantono1p = $('.payment_update_form select[name="payment_update_canton"]')
.find("option:selected")
.html();
if (provinces[provin][cantono] != "undefined") {
$.each(provinces[provin][cantono], function (key, value) {
var option =
"";
$('#shipping-new select[name="shipping_new_district"]').append(option);
});
}
if (provinces[provinp][cantonop] != "undefined") {
$.each(provinces[provinp][cantonop], function (key, value) {
var option =
"";
$('#payment-new select[name="payment_new_district"]').append(option);
});
}
if (provinces[provin1][cantono1] != "undefined") {
$.each(provinces[provin1][cantono1], function (key, value) {
var option =
"";
$('.shipping_update_form select[name="shipping_update_district"]').append(
option
);
});
}
if (provinces[provin1p][cantono1p] != "undefined") {
$.each(provinces[provin1p][cantono1p], function (key, value) {
var option =
"";
$('.payment_update_form select[name="payment_update_district"]').append(
option
);
});
}
$('.shipping_update_form select[name="shipping_update_district"]').val(
'.shipping_update_form select[name="shipping_update_district_holder"]'
);
$('.payment_update_form select[name="payment_update_district"]').val(
'.payment_update_form select[name="payment_update_district_holder"]'
);
}
function setDefaultsForAll() {
if (payment_form === "payment_confirmation") {
setDefaultsForUnsignedDetailsSection();
} else {
setDefaultsForPaymentDetailsSection();
}
}
function addLinkToSetDefaults() {
$(".section")
.prev()
.each(function (i) {
legendText = $(this).text();
$(this).text("");
var setDefaultMethod =
"setDefaultsFor" + capitalize($(this).next().attr("id")) + "()";
newlink = $(document.createElement("a"));
newlink.attr({
id: "link-" + i,
name: "link" + i,
href: "#",
});
newlink.append(document.createTextNode(legendText));
newlink.bind("click", function () {
eval(setDefaultMethod);
});
$(this).append(newlink);
});
newbutton = $(document.createElement("input"));
newbutton.attr({
id: "defaultAll",
value: "Default All",
type: "button",
onClick: "setDefaultsForAll()",
});
newbutton.bind("click", function () {
setDefaultsForAll;
});
$("#" + payment_form).append(newbutton);
}
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function setDefaultsForPaymentDetailsSection() {
$("input[name='transaction_type']").val("authorization");
// $("input[name='reference_number']").val(new Date().getTime());
$("#js_time").val(new Date().getTime());
$("input[name='amount']").val("10.00");
$("input[name='currency']").val("USD");
/* $("input[name='payment_method']").val("card");
$("input[name='bill_to_forename']").val("John");
$("input[name='bill_to_surname']").val("Doe");
$("input[name='bill_to_email']").val("null@cybersource.com");
$("input[name='bill_to_phone']").val("02890888888");
$("input[name='bill_to_address_line1']").val("1 Card Lane");
$("input[name='bill_to_address_city']").val("My City");
$("input[name='bill_to_address_state']").val("CA");
$("input[name='bill_to_address_country']").val("US");
$("input[name='bill_to_address_postal_code']").val("94043");*/
//2222 4200 0000 1113
var diff =
$("#js_time").val() / 1000 - $("input[name='reference_number']").val();
$("#js_time_diff").val(diff);
}
function setDefaultsForUnsignedDetailsSection() {
$("input[name='card_type']").val("001");
$("input[name='card_number']").val("4242424242424242");
$("input[name='card_expiry_date']").val("11-2020");
}
$(document).ready(function () {
/*
if($('#category .category-image').length > 0) {
if (prestashop.language.iso_code == 'en') {
var url = "https://payless.cr/img/c/other/CR-Flash-sale-1000x200-ENG.jpg";
}
if (prestashop.language.iso_code == 'es' || prestashop.language.iso_code == 'cb') {
var url = "https://payless.cr/img/c/other/CR-Flash-sale-1000x200-SPA.jpg";
}
flash sale
if (prestashop.language.iso_code == 'en') {
var url = "https://payless.cr/img/c/other/CR-Flash-sale-1000x200-ENG.jpg";
}
if (prestashop.language.iso_code == 'es' || prestashop.language.iso_code == 'cb') {
var url = "https://payless.cr/img/c/other/CR-Flash-sale-1000x200-SPA.jpg";
}
//bts bogo
if (prestashop.language.iso_code == 'en') {
var url = "https://payless.cr/img/c/other/BTS-50-1000x200-ENG.jpg";
}
if (prestashop.language.iso_code == 'es' || prestashop.language.iso_code == 'cb') {
var url = "https://payless.cr/img/c/other/BTS-50-1000x200-SPA.jpg";
}
GranLiquidacion-1000x200-ENG.jpg";
CAMBIO DE BANNERS PLP plp
*/
function get_program_banner_CrBannerUrlESP() {
// Get today's date
const today = new Date();
// Set the date for Mining Colombia
const eventDate = new Date("2024-11-22 00:00:00");
// Set image URLs
const eventImageUrl = "/img/c/other/40OffOnline-CR_SV-1000x200-SPA.jpg";
const defaultImageUrl =
"https://payless.cr/img/c/other/40OffOnline-CR_SV-1000x200-ENG.jpg";
// Check if today is the event date and return the corresponding URL
return today.toDateString() === eventDate.toDateString()
? eventImageUrl
: defaultImageUrl;
}
function get_program_banner_CrBannerUrlENG() {
// Get today's date
const today = new Date();
// Set the date for Mining Colombia
const eventDate = new Date("2024-11-22 00:00:00");
// Set image URLs
const eventImageUrl = "/img/c/other/40OffOnline-CR_SV-1000x200-ENG.jpg";
const defaultImageUrl =
"https://payless.cr/img/c/other/40OffOnline-GT_HN-1920x500-SPA.jpg";
// Check if today is the event date and return the corresponding URL
return today.toDateString() === eventDate.toDateString()
? eventImageUrl
: defaultImageUrl;
}
const urlArray = window.location.href.split("/");
if (prestashop.language.iso_code == "en") {
let url = "https://payless.cr/img/c/other/CAM-CA 50_1000x200 ENG.jpg"; // bogo CAM-CA-50off-1000x200-ENG.jpg
if (urlArray.includes("157-men")) {
url = "/img/category/Hombres ENG.jpg";
} else if (urlArray.includes("169-women")) {
url = "/img/category/Mujeres ENG.jpg";
} else if (urlArray.includes("231-girls")) {
url = "/img/category/Ninas ENG.jpg";
} else if (urlArray.includes("171-athletics") || urlArray.includes("159-athletics") || urlArray.includes("231-athletics") || urlArray.includes("245-athletics")) {
url = "/img/category/Atléticos ENG.jpg";
} else if (urlArray.includes("245-boys")) {
url = "/img/category/Hombres ENG.jpg";
} else if (urlArray.includes("259-accessories")) {
url = "/img/category/Accesorios ENG.jpg";
}
$("#category .category-image img").attr("src", url);
}
if (
prestashop.language.iso_code == "es" ||
prestashop.language.iso_code == "cb"
) {
let url = "https://payless.cr/img/c/other/CAM-CA 50_1000x200.jpg";; //CAM-CA-50off-1000x200-SPA.jpg
if (urlArray.includes("157-hombres")) {
url = "/img/category/Hombres ESP.jpg";
} else if (urlArray.includes("169-mujeres")) {
url = "/img/category/Mujeres ESP.jpg";
} else if (urlArray.includes("231-ninas")) {
url = "/img/category/Ninas ESP.jpg";
} else if (urlArray.includes("245-ninos")) {
url = "/img/category/Ninos ESP.jpg";
} else if (urlArray.includes("259-accesorios")) {
url = "/img/category/Accesorios ESP.jpg";
} else if (urlArray.includes("172-tenis-y-zapatos-deportivo") || urlArray.includes("159-tenis-y-zapatos-deportivo") || urlArray.includes("231-tenis-y-zapatos-deportivo") || urlArray.includes("245-tenis-y-zapatos-deportivo") ) {
url = "/img/category/Atléticos ESP.jpg";
}
$("#category .category-image img").attr("src", url);
}
$("body").on("click", ".js-increase-product-quantity", function () {
// if(!$(this).hasClass('disabled')) {
var that = this;
$(".js-decrease-product-quantity, .js-increase-product-quantity").attr(
"disabled",
"disabled"
);
setTimeout(function () {
$(
".js-decrease-product-quantity, .js-increase-product-quantity"
).removeAttr("disabled");
}, 5000);
});
$("body").on("click", ".js-decrease-product-quantity", function () {
// if(!$(this).hasClass('disabled')) {
var that = this;
$(".js-decrease-product-quantity, .js-increase-product-quantity").attr(
"disabled",
"disabled"
);
setTimeout(function () {
$(
".js-decrease-product-quantity, .js-increase-product-quantity"
).removeAttr("disabled");
}, 5000);
});
});
$(document).ready(function () {
if ($("#module-supercheckout-supercheckout").length > 0) {
var iqitpopup_c_payments_cr = {};
iqitpopup_c_payments_cr.script = (function () {
var $el = $("#iqitpopup_c_payments_cr");
var $overlay = $("#iqitpopup_c_payments_cr_overlay");
var elHeight = $el.outerHeight();
var elWidth = $el.outerWidth();
var $wrapper = $(window);
var offset = -30;
var sizeData = {
size: {
width: $wrapper.width() + offset,
height: $wrapper.height() + offset,
},
};
function init() {
setTimeout(function () {
$el.addClass("showed-iqitpopup");
$overlay.addClass("showed-iqitpopupo");
}, iqitpopup.delay);
$el
.find(".iqit-btn-newsletter")
.first()
.click(function () {
setCookie();
$overlay.removeClass("showed-iqitpopupo");
$el.removeClass("showed-iqitpopup");
});
/* $(document).on('click', '#iqitpopup_c_payments_cr .cross, #iqitpopup_c_payments_cr_overlay', function () {
$overlay.removeClass('showed-iqitpopupo');
$el.removeClass('showed-iqitpopup');
if ($("#iqitpopup-checkbox").is(':checked')) {
setCookie();
}
});*/
doResize(sizeData, false);
$wrapper.resize(function () {
sizeData.size.width = $wrapper.width() + offset;
sizeData.size.height = $wrapper.height() + offset;
doResize(sizeData, true);
});
}
function doResize(ui, resize) {
if (elWidth >= ui.size.width || elHeight >= ui.size.height) {
var scale;
scale = Math.min(
ui.size.width / elWidth,
ui.size.height / elHeight
);
$el.css({
transform: "translate(-50%, -50%) scale(" + scale + ")",
});
} else {
if (resize) {
$el.css({
transform: "translate(-50%, -50%) scale(1)",
});
}
}
}
function setCookie() {
/* var name = iqitpopup.name;
var value = '1';
var expire = new Date();
expire.setDate(expire.getDate() + iqitpopup.time);
document.cookie = name + "=" + escape(value) + ";path=/;" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))*/
}
return { init: init };
})();
iqitpopup_c_payments_cr.script.init();
$(document).on(
"click",
'#payment-method input[name="payment_method"]',
function () {
iqitpopup_c_payments_cr.script.init();
}
);
$("#module-supercheckout-supercheckout .button-agree").on(
"click",
function () {
$("#iqitpopup_c_payments_cr_overlay").removeClass("showed-iqitpopupo");
$("#iqitpopup_c_payments_cr").removeClass("showed-iqitpopup");
}
);
}
});
/*------------------------*\
| - Marcas de Costa Rica - |
\*------------------------*/
function removeBrands() {
const pag = window.location.pathname;
if (pag === "/es/marcas") {
const items = document.querySelectorAll("div.ms-grid div.brand");
if (items) {
items[5].remove();
items[16].remove();
items[19].remove();
items[20].remove();
items[29].remove();
items[33].remove();
}
}
}
// Remover texto carrito
function deleteTextCarrito() {
const textoContenedor = document.querySelectorAll(".cart-grid-body > div")[1];
if (textoContenedor) {
textoContenedor.remove();
}
}
// Remover texto HOME
function deleteBannerText() {
const bannerCntenedor = document.querySelector(".elementor-column-wrap");
if (bannerCntenedor) {
bannerCntenedor.remove();
}
}
// Function manager
function checkUrl() {
const url = window.location.pathname;
const homeUrl = window.location.pathname.replaceAll("/", "");
if (homeUrl === "en" || homeUrl === "es") {
deleteBannerText();
}
if (url.includes("cart")) {
deleteTextCarrito();
//removeOldPromosCheckout();
removeEmptyTextCart();
}
}
// Ejecutar funcion
document.addEventListener("DOMContentLoaded", () => {
//removeOldPromosCheckout();
removeOnDesk();
removeOnMobile();
if (!checkIfCheckout()) {
checkUrl();
removeBrands();
deleteCurrency();
if (window.innerWidth < 768) {
document
.querySelector(
"#mobile-header-sticky > div > div.mobile-main-bar > div > div.languageContainer"
)
.appendChild(document.querySelector("#language_selector"));
}
}
});
function deleteCurrency() {
const currency = document.querySelector("#currency_selector");
if (currency) {
currency.remove();
}
}
function manageMutationVitrina() {
const target = document.querySelector("#products");
if (!target) return;
const config = { attributes: false, childList: true, subtree: true };
const callback = function (mutationsList, observer) {
for (const mutation of mutationsList) {
if (mutation.type === "childList") {
debounce(repairSrcVitrina(), 1000);
}
}
};
const observer = new MutationObserver(callback);
observer.observe(target, config);
}
function repairSrcVitrina(intento = 0) {
if (intento === 0) {
setTimeout(() => repairSrcVitrina(1), 15000);
setTimeout(() => repairSrcVitrina(1), 3000);
}
const changeAttr = ["data-src", "src", "data-full-size-image-url"];
const items = document.querySelectorAll(".thumbnail-container");
if (!items) return;
items.forEach((item) => {
const imgs = item.querySelectorAll("img");
imgs.forEach((img) => {
if (!img.classList.contains("error")) return;
if (img.classList.contains("fixed")) return;
changeAttr.forEach((attr) => {
const src = img.getAttribute(attr);
if (src) {
const newSrc = src.replace("payless.cr", "paylesscolombia.co");
img.setAttribute(attr, newSrc);
}
});
img.classList.add("fixed");
});
});
}
document.addEventListener("DOMContentLoaded", () => {
//removeOldPromosCheckout();
if (!checkIfCheckout()) {
checkUrl();
addVerTodoItems();
convertAnchorsToTitleCase();
clicksQty();
setTimeout(() => {
addQtyProducts();
}, 2500);
removeEmptyTextCart();
insertWhatsappIcon();
repairSrcVitrina();
repairSrcProduct();
manageMutationVitrina();
const debouncedRepairSrcVitrina = debounce(repairSrcVitrina, 500);
window.addEventListener("scroll", debouncedRepairSrcVitrina);
}
});
function checkIfCheckout() {
const url = window.location.pathname;
if (url.includes("/supercheckout/supercheckout")) {
return true;
}
return false;
}
function debounce(func, wait, immediate) {
let timeout;
return function () {
const context = this;
const args = arguments;
const later = function () {
timeout = null;
if (!immediate) func.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
function repairSrcProduct() {
const changeAttr = [
"data-src",
"src",
"data-image-large-src",
"data-image-medium-src",
"data-image-small-src",
];
const items = document.querySelector(".images-container");
if (!items) return;
const imgs = items.querySelectorAll("img");
imgs.forEach((img) => {
if (img.classList.contains("fixed")) return;
let srcReplaced = false;
changeAttr.forEach((attr) => {
const src = img.getAttribute(attr);
if (src && !srcReplaced) {
const testImg = new Image();
testImg.onload = () => {
srcReplaced = true;
};
testImg.onerror = () => {
const newSrc = src.replace("payless.cr", "paylesscolombia.co");
img.setAttribute(attr, newSrc);
srcReplaced = true;
};
testImg.src = src;
}
});
if (srcReplaced) {
img.classList.add("fixed");
}
});
}
function moveElementToTop() {
const parent = document.querySelector("#content");
const elementSpa = document.querySelector(".elementor-element-teka90g");
const elementEng = document.querySelector(".elementor-element-cqkqnin");
const element = elementSpa ?? elementEng;
if (!parent || !element) {
return;
}
parent.insertBefore(element, parent.firstChild);
}
function insertWhatsappIcon() {
const mainPage = document.getElementById("main-page-content");
if (!mainPage) return console.log("No main page found");
if (document.querySelector(".wp-icon")) {
return console.log("Whatsapp icon already inserted");
}
const imgSrc = "https://www.payless.cr/img/c/other/wp-icon.png";
const imgHoverSrc = "https://www.payless.cr/img/c/other/wp-hover.png";
const whatsappUrl = "https://api.whatsapp.com/send?phone=50670964289&text=Hola%20Payless!";
// Create anchor element
const anchor = document.createElement("a");
anchor.href = whatsappUrl;
anchor.target = "_blank";
anchor.style.position = "fixed";
anchor.style.bottom = "20px";
anchor.style.right = "20px";
anchor.style.zIndex = "9999";
anchor.style.cursor = "pointer";
anchor.style.transition = "all 0.3s ease-in-out";
anchor.style.display = "block"; // Ensure proper layout
anchor.title = "Chat con nosotros en WhatsApp"; // Improved accessibility
// Create image element
const img = document.createElement("img");
img.classList.add("wp-icon");
img.src = imgSrc;
img.style.width = "60px";
img.style.height = "60px";
img.alt = "WhatsApp Icon";
// Add hover effects
img.addEventListener("mouseover", () => img.src = imgHoverSrc);
img.addEventListener("mouseout", () => img.src = imgSrc);
// Assemble elements
anchor.appendChild(img);
mainPage.appendChild(anchor);
}
function removeEmptyTextCart() {
// aloha
if (document.querySelector(".no-items")) {
document.querySelector(".cart-toggle-details").textContent = document
.querySelector(".cart-toggle-details")
.textContent.replace(" Vacio", "")
.replace("/", "")
.replace(" Vacío", "");
document.querySelector(".cart-toggle-details").textContent = document
.querySelector(".cart-toggle-details")
.textContent.replace(" Empty", "")
.replace("/", "");
}
if (document.querySelector(".input-subscription")) {
document.querySelector(".input-subscription").placeholder =
"Escribe tu correo";
}
}
function addQtyProducts() {
console.log("Adding quantity products");
const qtyProducts = document.querySelectorAll(
".input-group.form-control.input-qty"
);
console.log("qty", qtyProducts);
qtyProducts.forEach(function (quantity) {
if (!quantity) return;
quantity.setAttribute("value", 1);
console.log(quantity);
});
}
function clicksQty() {
const navItems = document.querySelectorAll(".nav-item");
navItems.forEach((item) => {
item.addEventListener("click", () => {
setTimeout(() => {
addQtyProducts();
}, 1000);
});
});
}
function getCountry() {
const url = window.location.href;
const country = url.split("/")[3];
console.log(country);
return country;
}
function clone() {
if ($(".blockreassurance_product").length > 0) {
if (
$("#main-product-wrapper .tabs.product-tabs .blockreassurance_product")
.length == 0
) {
$(".blockreassurance_product").clone().appendTo(".tabs.product-tabs");
}
} else {
}
}
$(document).ready(function () {
if (window.location.search == "?prueba") {
formePartner2();
}
clone();
topbarAnimateText();
topbarAnimateTextMobile();
var variable = $("body").attr("id");
if (variable == "category") {
// formePartner();
}
enviarePartner();
updateDate18years();
const closeCartButton = document.querySelector(
".search_menu_mobile_close button"
);
if (!closeCartButton) return;
closeCartButton.addEventListener("click", function (e) {
e.preventDefault();
document
.querySelector(
"#mobile-header-sticky > div > div.mobile-main-bar > div > div.col.col-auto.col-mobile-btn.col-mobile-btn-menu.col-mobile-menu-push.show"
)
.classList.remove("show");
});
});
const textsSpa = [
{
title: "Envío gratuito",
text: "a tu domicilio cuando compras dos o más artículos!",
icon: "/modules/blockreassurance/views/img/img_perso/Icon-03.png",
},
// {
// title: "En esta temporada",
// text: "Podrían ocurrir retrasos en los tiempos de tránsito. Gracias por tu paciencia y comprensión. 😊",
// icon: "/modules/blockreassurance/views/img/img_perso/rejocDemora.png",
// },
{
title: "Pago 100% Seguro",
text: "Estricta protección de los datos a través de todos los métodos de pago.",
icon: "/modules/blockreassurance/views/img/img_perso/Icon-02.png",
}
];
// text eng
const textsEng = [
{
title: "Free shipping",
text: "to your home when you buy two or more articles!",
icon: "/modules/blockreassurance/views/img/img_perso/Icon-03.png",
},
// {
// title: "In this season",
// text: "Podrían ocurrir retrasos en los tiempos de tránsito. Gracias por tu paciencia y comprensión. 😊",
// icon: "/modules/blockreassurance/views/img/img_perso/rejocDemora.png",
// },
{
title: "Secure payment",
text: "Strict protection of data through all payment methods.",
icon: "/modules/blockreassurance/views/img/img_perso/Icon-02.png",
}
];
function topbarAnimateText() {
const isEng = document.body.classList.contains("lang-en");
const textsArray = isEng ? textsEng : textsSpa;
const texts = textsArray;
const topbar = document.querySelector(".header-banner.textTop");
if (!topbar) return console.log("No topbar found");
if (topbar.classList.contains("carrousel-top"))
return console.log("Already animated");
let index = 0;
setInterval(() => {
topbar.innerHTML = `
${texts[index].title}
${texts[index].text}
`;
index = (index + 1) % texts.length;
}, 5000);
console.log("topbarAnimateText");
topbar.classList.add("carrousel-top");
}
function calculateFreeShipping() {
const products = document.querySelector(
"span.cart-products-count-btn"
).textContent;
const freeShippingProducts = 2;
if (!products) {
console.error("No products found");
return;
}
const isFree = parseInt(products) >= freeShippingProducts;
// const isFree = true; // 22 nov
// document.querySelectorAll('.freeshipping-body p').forEach(p => {
// p.classList.length === 0 ? p.innerText = "Envío gratis todo el día 🎀" : ""
// })
if (isFree) {
if (window.innerWidth < 768) {
const mobileContainer = document.querySelector(
"#_mobile_blockcart-content"
);
// mobile
mobileContainer.querySelector(".notFree").classList.add("hidden");
mobileContainer.querySelector(".free").classList.remove("hidden");
const barThumbmobileContainer = mobileContainer.querySelector(
".freeshipping-bar-thumb"
);
barThumbmobileContainer.classList.add("full");
barThumbmobileContainer.style.width = "100%";
return;
}
// desk
const deskContainer = document.querySelector("#_desktop_blockcart-content");
if (!deskContainer.querySelector(".notFree")) return;
deskContainer.querySelector(".notFree").classList.add("hidden");
deskContainer.querySelector(".free").classList.remove("hidden");
const barThumbdeskContainer = deskContainer.querySelector(
".freeshipping-bar-thumb"
);
barThumbdeskContainer.classList.add("full");
barThumbdeskContainer.style.width = "100%";
return;
}
if (window.innerWidth < 768) {
const mobileContainer = document.querySelector(
"#_mobile_blockcart-content"
);
// mobile
const barThumbmobileContainer = mobileContainer.querySelector(
".freeshipping-bar-thumb"
);
console.log("barThumbmobileContainer", barThumbmobileContainer);
// mobileContainer.querySelector(".notFree").innerHTML = `Te falta agregar
// ${
// freeShippingProducts - parseInt(products) < 0
// ? 0
// : freeShippingProducts - parseInt(products)
// }
// un articulo para ¡ENVÍO GRATIS!`;
if (!mobileContainer.querySelector(".notFree")) return;
mobileContainer.querySelector(".notFree").innerHTML =
"Te falta agregar un articulo para ¡ENVÍO GRATIS!";
mobileContainer.querySelector(".notFree").classList.remove("hidden");
mobileContainer.querySelector(".free").classList.add("hidden");
// 2 products = 100%
const percentage = (parseInt(products) / freeShippingProducts) * 100;
console.log("percentage", percentage);
barThumbmobileContainer.style.width = `${percentage}%`;
barThumbmobileContainer.classList.remove("full");
return;
}
// desk
const deskContainer = document.querySelector("#_desktop_blockcart-content");
const barThumbdeskContainer = deskContainer.querySelector(
".freeshipping-bar-thumb"
);
console.log("barThumbdeskContainer", barThumbdeskContainer);
// deskContainer.querySelector(".notFree").innerHTML = `Te falta ${
// freeShippingProducts - parseInt(products) < 0
// ? 0
// : freeShippingProducts - parseInt(products)
// } producto para ¡ENVÍO GRATIS!`;
if (!deskContainer.querySelector(".notFree")) return;
deskContainer.querySelector(".notFree").innerHTML =
"Te falta agregar un articulo para ¡ENVÍO GRATIS!";
deskContainer.querySelector(".notFree").classList.remove("hidden");
deskContainer.querySelector(".free").classList.add("hidden");
// 2 products = 100%
const percentage = (parseInt(products) / freeShippingProducts) * 100;
console.log("percentage", percentage);
barThumbdeskContainer.style.width = `${percentage}%`;
barThumbdeskContainer.classList.remove("full");
}
function injectFreeShippingBox() {
// Check if the box is already injected to avoid duplicates
if (document.querySelector(".freeshippingbar-box")) return;
var cartSubtotals = document.querySelector(".cart-subtotals");
if (cartSubtotals) {
cartSubtotals.insertAdjacentHTML("afterend", freeShippingBoxHTML);
// After injecting, you might want to call any functions to initialize the box or update its content
calculateFreeShipping(); // Adjust this function for PrestaShop context
}
}
function checkUrl() {
document.querySelector("#blockcart").classList.add("mockup");
closeMobilemenu();
sendSearchOnClick();
calculateFreeShipping();
// Listen for PrestaShop cart update event and re-inject if necessary
prestashop.on("updatedCart", function () {
setTimeout(() => {
openCartAfterAdd();
calculateFreeShipping();
}, 600);
});
if (!document.querySelector(".cart-buttons .btn-primary")) return;
document.querySelector(".cart-buttons .btn-primary").innerText =
"Cerrar pedido";
}
function changeQuantity(
minimal_quantity,
operator,
id,
id_attribute,
quantincart
) {
document.querySelector("#blockcart").classList.add("show-custom");
document.querySelector("#ps-shoppingcart").classList.add("show-custom");
var token = prestashop.static_token; //important for logged user
if (operator == 1) {
//subtract
var actionURL = "/index.php";
var query =
"controller=cart&add=1&action=update&ajax=true&qty=1&op=down&token=" +
token +
"&id_product=" +
id +
"&ipa=" +
id_attribute;
$.post(actionURL, query, null, "json")
.then(function (resp) {
prestashop.emit("updateCart", {
reason: resp,
});
console.log(resp);
openCartAfterAdd();
})
.fail(function (resp) {
prestashop.emit("handleError", {
eventType: "addProductToCart",
resp: resp,
});
});
} else if (operator == 2) {
//sum
var actionURL = "/index.php";
var query =
"controller=cart&add=1&action=update&ajax=true&qty=1&op=up&token=" +
token +
"&id_product=" +
id +
"&ipa=" +
id_attribute;
$.post(actionURL, query, null, "json")
.then(function (resp) {
prestashop.emit("updateCart", {
reason: resp,
});
console.log(resp);
openCartAfterAdd();
})
.fail(function (resp) {
prestashop.emit("handleError", {
eventType: "addProductToCart",
resp: resp,
});
});
} else if (operator == 3) {
//delete
var actionURL = "/index.php";
var query =
"controller=cart&add=1&action=update&ajax=true&qty=" +
quantincart +
"&op=down&token=" +
token +
"&id_product=" +
id +
"&ipa=" +
id_attribute;
$.post(actionURL, query, null, "json")
.then(function (resp) {
prestashop.emit("updateCart", {
reason: resp,
});
openCartAfterAdd();
})
.fail(function (resp) {
prestashop.emit("handleError", {
eventType: "addProductToCart",
resp: resp,
});
});
}
}
function formatPrice(price) {
return price
.toLocaleString("es-CO", {
style: "currency",
currency: "COP",
})
.replace(",00", "");
}
function openCartAfterAdd() {
setTimeout(() => {
const closeCartButton = document.querySelector(
".cart-buttons .btn.btn-secondary.btn-block"
);
closeCartButton.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector("#blockcart").classList.remove("show");
});
document.querySelector("#blockcart").classList.add("show");
if (window.innerWidth < 1000) {
document.querySelector("#mobile-cart-wrapper").classList.add("show");
}
document.querySelector("#blockcart").classList.remove("show-custom");
document.querySelector("#ps-shoppingcart").classList.remove("show-custom");
}, 400);
}
// Eliminar cupones de BOGO o otras promos
function removeOldPromosCheckout() {
setTimeout(() => {
const cartUrl = "/cart?action=show";
const today = new Date();
const cartUrlSpa = "/carrito?action=show";
const checkoutUrl = "/pedido";
const checkoutUrlEng = "/order";
const currentUrl = window.location.pathname + window.location.search;
const eventDate = new Date("2024-10-25 00:00:00");
// if(today.toDateString() === eventDate.toDateString()){
// if (currentUrl.includes(cartUrl) || currentUrl.includes(cartUrlSpa)) {
// const promoCodes = document.querySelectorAll(".promo-name li a");
// promoCodes.forEach((promoCode) => {
// if (
// promoCode.parentNode
// .querySelector("span")
// .textContent.includes("BOGO")
// ) {
// setTimeout(() => {
// promoCode.click();
// console.log("click");
// }, 1000);
// }
// });
// }
// }
if (currentUrl.includes(cartUrl) || currentUrl.includes(cartUrlSpa)) {
const promoCodes = document.querySelectorAll(".promo-name li a");
promoCodes.forEach((promoCode) => {
if (
promoCode.parentNode
.querySelector("span")
.textContent.includes("BOGO") //BOGO - Compra ||
||
promoCode.parentNode
.querySelector("span")
.textContent.includes("Compra")
) {
setTimeout(() => {
promoCode.click();
console.log("click");
}, 1000);
location.reload();
}
});
}
/* else if (
currentUrl.includes(checkoutUrl) ||
currentUrl.includes(checkoutUrlEng)
) {
const promoCodes = document.querySelectorAll(".promo-name li a");
promoCodes.forEach((promoCode) => {
setTimeout(() => {
promoCode.click();
}, 2500);
});
} */
}, 2400);
}
function formePartner() {
console.log("cargueform");
$("#main-page-content").append(
'
Tu suscripción ha sido exitosa