Desc. 20%
";
//msgCouponGroupMovil = "';
items += '
';
// Imagen del producto
items += '
';
var imgItemProduct = "";
if(value.image.url_thumbnail != 'https://'){
imgItemProduct = value.image.url_thumbnail;
}else{
imgItemProduct = value.image.url;
}
var nameSLUGCart = limpiarSLUGname(value.name);
if (!value.image) {
items += '
';
} else {
if(value.tflon){
items += '
';
}else{
items += '
';
}
}
items += '
';
var itemDesc = "";
if(data["2x1.5"]){
if(data["2x1.5"][idProducto]){
// console.log("Entra A - "+value.name);
itemDesc += '
-'+setFormatMoney(data["2x1.5"][idProducto].monto)+' (Desc. 2x1.5) ';
}else{
// console.log("Entra B - "+value.name);
//itemDesc += '
-'+ setFormatMoney(value.subtotal) +' ';
itemDesc += msgCouponGroupMovil;
}
}else{
// console.log("Entra C - "+value.name);
// itemDesc += '
-'+ setFormatMoney(value.subtotal) +' ';
itemDesc += msgCouponGroupMovil
}
// Nombre , precio y promociones
items += '
';
var price_item = 0;
if(value.tflon){
items += '
' + value.name + ' ';
if(value.active_tflon == "yes"){
price_item = value.subtotal;
}else{
price_item = value.price * value.quantity;
}
}else{
items += '
' + value.name + ' ';
price_item = value.subtotal;
}
items += '
'+mensaje+' ';
items += '
'+setFormatMoney(price_item)+' ';
items += '
'+setFormatMoney(price_item)+' ';
items += itemDesc;
items += '
';
// Cuando me llega
items += '
'+mensaje+'
';
// Cantidad
if(value.tflon){
items += "
";
quantityProdSelect = "quantityProdSelect-" + idProducto;
quantityProdCustom = "quantityProdCustom-" + idProducto;
items += ' ';
items += "
";
// items += '
';
items += "";
}else{
items += "
";
select = "";
input = "style='display:none;' disabled";
if (value.quantity > 6) {
select = 'style="display:none;"';
input = 'style="display:block;"';
}
quantityProdSelect = "quantityProdSelect-" + idProducto;
quantityProdCustom = "quantityProdCustom-" + idProducto;
// items += "";
items += "";
for (let i = 1; i <= 6; i++) {
selected = '';
if (i == value.quantity) { selected = 'selected'; }
items += '' + i + ' ';
}
items += 'más unidades ';
items += " ";
items += ' ";
items += input + " onkeypress='return validJustNumbers(event);' id='quantityProdCustom-" + idProducto + "'/>";
items += "
";
// items += '
';
items += "";
}
// Boton eliminar o switch Tflon
if(!value.tflon){
items += "
';
items += "";
}else{
is_active_tflon = "";
// console.log("Checkbox: "+ value.name + " --> "+ value.active_tflon);
if(value.active_tflon == "yes"){ is_active_tflon = "checked"; }
// console.log(is_active_tflon);
items += "";
items += '
';
items += "";
}
items += '
';
});
$(".trAddCoupones").remove();
if(data.coupon != false ){
// console.log("-------------------Agregando cupones------------------------------");
// console.log("Cupones: "+ JSON.stringify(data.coupon));
// console.log("No de cupones: "+ data.coupon.code_data.length);
var objNuevo = data.coupon.code_data;
var objNuevoSap = data.coupon.data;
var objDesCupones = data.coupon.discount_value;
var subtotal = 0;
var trCuponManual = "";
var trCuponAuto = "";
var trCouponAll = "";
$.each(objNuevo, function (key, value){
var itemCuponSAP = objNuevoSap.find(cupon => cupon.id === value.coupon_id);
var valDiscount = parseFloat(objDesCupones[key]);
// console.log( "Key: "+ key +" value: "+ valDiscount + " - "+ value.code);
if(itemCuponSAP.automatic ==='no'){
trCouponAll += "
" + "" +
' ' + value.code +
" " +
'-$' + valDiscount.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN" +
" " + " ";
trCuponManual += "
" + "" +
' ' + value.code +
" " +
'-$' + valDiscount.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN" +
" " + " ";
// if(valDiscount == 0 && value.code== "PREVENTA"){
if(valDiscount == 0){
cuponenceros = value.code;
}
totalCuponesManual += valDiscount;
}else{
trCouponAll += "
" + "" +
value.code +
" " + '-$' + valDiscount.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN" +
" " + " ";
trCuponAuto += "
" + "" +
value.code +
" " + '-$' + valDiscount.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN" +
" " + " ";
totalCuponesAuto += valDiscount;
}
});
totalCupones = totalCuponesAuto + totalCuponesManual;
// console.log("Total cupones Auto: "+ totalCuponesAuto);
// console.log("Total Cupones Manuales: "+ totalCuponesManual);
$("#tr_cupones").after(trCouponAll);
/*$("#tr_cupones").after(trCuponManual);
if(totalCuponesAuto>0){
$("#tr_cupones").after(trCuponAuto);
}*/
}
noProductosActivos = noProductos + noProductosTflon ;
if(totalTeflon == 0){
$("#tr_Tflon").hide();
}else{
$("#tr_Tflon").show();
}
$('#itemsCart').html(items);
$("#td_totalProd").html("Productos(" + noProductos + ")");
$("#td_textTflon").html("t-Flon(" + noProductosTflon + ")");
$("#td_subtotal").html(setFormatMoney(totalProductos));
$("#td_totalTflon").html(setFormatMoney(totalTeflon));
$("#td_shipping").html(setFormatMoney(data.shipping));
montoTotalCarrito = totalProductos + totalTeflon + data.shipping - totalCupones;
//validar leyenda de envio o servicio de entrega y MCI
var Tot_Env = Math.round(montoTotalCarrito);
var valueInterest = (Tot_Env*.009)*18;
var Mensualidad = (Tot_Env+valueInterest)/18;
if(Tot_Env >= 1800){
$(".total-MCI span b").html(setFormatMoneyMens(Mensualidad));
$(".total-MCI span").css({ display: "block"});
if(Tot_Env >= 5000){
$(".serv-entrega").css({ display: "block"});
$(".serv-envio").css({ display: "none"});
}else{
$(".serv-entrega").css({ display: "none"});
$(".serv-envio").css({ display: "block"});
}
}else{
$(".total-MCI span").css({ display: "none"});
$(".serv-entrega").css({ display: "none"});
$(".serv-envio").css({ display: "block"});
};
$("#total").html(setFormatMoney(montoTotalCarrito));
$('#itemsCartTotal').html(setFormatMoney(montoTotalCarrito));
$('.bubble').html(noProductosActivos);
$('#btnIr').html('
Comenzar compra ');
if(cuponenceros == ""){
$("#btnStarShopping").removeAttr("disabled");
$("#btnStarShopping").removeClass("disabledElement");
}else{
$("#btnStarShopping").attr("disabled","disabled");
$("#btnStarShopping").addClass("disabledElement");
}
imgError("imgProduct");
allTeflonChecked();
productosRelacionadosCarrito();
checkMissing();
}
function shippingDate(date){
tempDate = date.getTime();
if(dateShippingTemp == null){
dateShippingTemp == new Date().getTime();
} else {
dateShippingTemp = dateShippingTemp.getTime();
}
if(tempDate > dateShippingTemp){
dateShippingTemp = new Date(tempDate);
}else{
dateShippingTemp = new Date(dateShippingTemp);
}
}
function getIdProducto(obj) {
// tr = $(obj).closest('tr');
// idPro = tr.find('td:eq(0)').text();
return $(obj).attr("itemId");
}
function showMessageCoupon(){
if (cuponesMonto.length > 0){
var tempCoupon = parseFloat(cuponesMonto[0].monto);
var textTemp = "El cupón que ingresaste con nombre: "+ cuponesMonto[0].nombre
+" es válido en compras mínimas a "
+ setFormatMoney(tempCoupon)
+". Para poder utilizarlo, debes agregar más productos a tu carrito.";
//$("#textMensaje").html(textTemp);
//$("#textMensaje").show();
//$("#bnrCart").hide();
//$("#bnrCart").html("
"+textTemp+"
");
$("#btnStarShopping").attr("disabled",true);
$("#btnStarShopping").addClass("disabledElement");
}else{
//$("#textMensaje").hide();
//$("#bnrCart").hide();
//$("#bnrCart").html("");
$("#btnStarShopping").attr("disabled",false);
$("#btnStarShopping").removeClass("disabledElement");
}
}
function updateCouponAmount(item,id){
if(id===null){
cuponesMonto.push(item);
}else{
for (const key in cuponesMonto) {
if(id === cuponesMonto[key].id ){
cuponesMonto.splice(key,1);
}
}
}
showMessageCoupon();
}
function addCouponAmount(data){
cuponesMonto = [];
var jsonCupon = data.coupon;
var itemDiscount = 0;
for (const key in jsonCupon.code_data) {
var itemSAP = jsonCupon.data[key];
if(itemSAP.valid){
itemDiscount = parseFloat(jsonCupon.discount_value[key]);
if(itemDiscount === 0){
var amountCoupon = parseFloat(itemSAP.flag_min_purchase_amount);
updateCouponAmount({id: itemSAP.id,nombre:jsonCupon.code_data[key].code,monto:amountCoupon},null);
}else{
updateCouponAmount(null,itemSAP.id);
}
}else{
updateCouponAmount(null,itemSAP.id);
}
}
}
function viewCupon() {
$('#cuponesDesc').on('click', function (event) {
$(this).css({ 'display': 'none' });
$('#addcupon').css({ 'display': 'table-row' });
$("#numCupon").focus();
});
$('#numCupon').blur(function () {
// console.log("entra viewCupon()")
numcup = $("#numCupon").val();
if (numcup == "") {
$('#addcupon').css({ 'display': 'none' });
$('#cuponesDesc').css({ 'display': 'revert' });
} else {
}
});
}
function agregarProductosCarrito(){
$(document).on('click', '.addtocartset', function (event) {
var arrProductos = [];
var tempArrayProductos= [];
if ($(this).attr('data-type') == "shoplook") {
tempArrayProductos = JSON.parse($(this).attr('arrPro'));
for (const key in tempArrayProductos) {
// arrProductos.push(tempArrayProductos[key]["id"]);
arrProductos.push(
{"id":tempArrayProductos[key]["id"], "typeVentaTodoMexico": tempArrayProductos[key]["venta_todo_mexico"] }
);
var jsonfbq = {
content_name: tempArrayProductos[key]['name'],
content_category: tempArrayProductos[key]["Category"][0]["slug"]+"/"+tempArrayProductos[key]["Subcategory"]["slug"],
content_ids: tempArrayProductos[key]["id"],
content_type: 'product',
quantity_product: 1,
value: tempArrayProductos[key]["price"],
currency: 'MXN'
};
fbq('track', 'AddToCart', jsonfbq);
// _etmc.push(["setOrgId", "526003570"]);
// _etmc.push(["setUserInfo", {"email": emailClientSalesforce}]);
// _etmc.push(["trackCart", { "cart": [{
// "item" : tempArrayProductos[key]["code"],
// "quantity": 1,
// "price" : tempArrayProductos[key]["price"],
// "unique_id" : tempArrayProductos[key]["code"]
// }]}]);
}
// console.log($(this).attr('arrPro'));
}
else {
// arrProductos.push($(this).attr('data-payload_id'));
arrProductos.push(
{"id":$(this).attr('data-payload_id'), "typeVentaTodoMexico": $(this).attr('data-typeVentaTodoMexico') }
);
console.log("---> agregarProductosCarrito else");
fbq('track', 'AddToCart', {
content_name: $(this).attr('data-payload_name'),
content_category: $(this).attr('data-payload_category')+"/"+$(this).attr('data-payload_subcategory'),
content_ids: $(this).attr('data-payload_id'),
content_type: 'product',
quantity_product: 1,
value: $(this).attr('data-payload_price'),
currency: 'MXN'
});
// _etmc.push(["setOrgId", "526003570"]);
// _etmc.push(["setUserInfo", {"email": emailClientSalesforce}]);
// _etmc.push(["trackCart", { "cart": [{
// "item" : $(this).attr('data-payload_code') ,
// "quantity": 1,
// "price" : $(this).attr('data-payload_price'),
// "unique_id" : $(this).attr('data-payload_code')
// }]}]);
}
// console.log(arrProductos2);
// return;
var cpSesion = localStorage.getItem("CP-envio");
var _this = this;
loadCartON();
$('#itemsCart').html("");
$("#listProductsRelated").html('');
openModal_MiCarrito();
$.ajax({
type: "POST",
url: "/shoppingcart/update_shop_look",
data: {
zip_code: cpSesion,
arr_shoplook: arrProductos
},
dataType: "json",
success: function (data) {
// console.log("Respuesta del controller");
// console.log(data);
if (data.result == 'ok') {
buscarCarrito();
sendGtag(extractGtagData(_this));
} else {
sendNoty("error", "Error");
}
// unblockUI();
},
error: function (e) {
sendNoty("error", "Error al agregar producto al carrito. Vuelva a intentarlo.");
console.log("Error al agregar producto al carrito");
console.log(e);
unblockUI();
}
});
return false;
});
}
var tempProductRelated = {} ;
function agregarReleatedCarrito(){
$(document).on('click', '.addtocartRelated', function (event) {
var _this = this;
tempProductRelated = {};
fbq('track', 'AddToCart', {
content_name: $(this).attr('data-payload_name'),
content_category: $(this).attr('data-payload_category')+"/"+$(this).attr('data-payload_subcategory'),
content_ids: $(this).attr('data-payload_id'),
content_type: 'product',
quantity_product: 1,
value: $(this).attr('data-payload_price'),
currency: 'MXN'
});
tempProductRelated = {
"id":$(this).attr('data-payload_id'),
"typeVentaTodoMexico": $(this).attr('data-typeVentaTodoMexico')
};
updateShoppingcart(parseInt($(this).attr("id").trim()), 1, 'addRelated', $(this).attr('data-payload_code'), $(this).attr('data-payload_price') );
sendGtag(extractGtagData(_this));
return;
});
}
function loadCartON(){
$('#loaderCarrito').show();
$('.recomendados.recomendados-carrito').hide();
$('#headerCartTeflon').hide();
$('#headerCartRes').hide();
$('#btnIr').hide();
$("#itemsCart").hide();
$("#productsRelated").hide();
$("#msgCarrito").hide();
offRecomendados();
}
function loadCartOFF(){
onRecomendados();
// $('#headerCartTeflon').show();
$('#headerCartRes').show();
$('#btnIr').show();
$("#itemsCart").show();
$("#productsRelated").show();
$("#msgCarrito").show();
$('#loaderCarrito').hide();
}
/*CARRUSEL NUEVO*/
function goCarouselHome() {
$(".carousel-beneficios").slick({
fade: false,
dots: false,
infinite: true,
centerMode: false,
slidesToShow: 4,
slidesToScroll: 1,
variableWidth: true,
arrows: false,
responsive: [{
breakpoint: 1024,
settings: {
centerMode: true
}
},
{
breakpoint: 780,
settings: {
arrows: false,
variableWidth: true,
slidesToShow: 1,
slidesToScroll: 1,
centerMode: false
}
},
{
breakpoint: 480,
settings: {
arrows: false,
variableWidth: true,
slidesToShow: 4,
slidesToScroll: 1,
centerMode: false
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
}
function goCarouselProduct() {
}
function productosRelacionadosCarrito(){
loadCartOFF();
$('#loaderCarrito').hide();
// console.log("Cierra el loader");
var parentwidth = $("#headerCartRes").width();
$("#btnIr").width(parentwidth);
if(banderaBannerTeflon){
$("#headerCartTeflon").show();
}else{
$("#headerCartTeflon").hide();
}
cartDown();
$.ajax({
type: "POST",
url: "/shoppingcart/get_productos_relacionados",
data: {
code_related : productoMasCaro['code']
},
dataType: "json",
success: function (data) {
if (data.result == 'ok') {
pintarCarruselCarrito(data['data']['product_relation_data']);
}else{
console.log("Error al consultar los productos relacionados");
console.log(data.msg);
loadCartOFF();
cartDown();
}
},
error: function (e) {
console.log("Error al buscar productos relacionados al mas caro");
console.log(e);
loadCartOFF();
}
});
}
function pintarCarruselCarrito(data){
//console.log(data);
var item = '';
for(const key in data) {
var value = data[key];
var imgItem = value.image;
if(value.url_thumbnail != 'https://'){
imgItem = value.url_thumbnail;
}else if(value.image == ""){
imgItem = "/images/products/default-image.jpg";
}else{
imgItem = value.image;
}
//validar leyenda de envio o servicio de entrega y MCI
var Tot_Env = value.price;
var valueInterest = (Tot_Env*.014)*18;
var Mensualidad = (Tot_Env+valueInterest)/18;
/*VALIDAR ETIQUETAS DE PROMOCION POR FECHA*/
var currentdate = new Date();
var elAno = currentdate.getFullYear();
var elMes = (currentdate.getMonth()+1);
var elDia = currentdate.getDate();
var laHora = currentdate.getHours();
var losMin = currentdate.getMinutes();
var losSeg = currentdate.getSeconds();
//limpiarSLUGname
var nameSLUG = limpiarSLUGname(value.name);
//var nameSLUG = value.name;
//var nameSLUG = nameSLUG.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
item += '
';
item += '
';
item += '
';
item += ' ';
item += ' ';
if(elDia >= 25 && elDia <= 28 && elMes === 11 && elAno === 2022){
item += '
-$500 x cada $2,500
';
}
if(value.only_store=="yes"){
item += '
exclusivo en tienda ';
}
item += '
';
item += '
'+value.name+'
';
if(value.price_old > value.price){
item += '
';
item += '
'+setFormatMoney(value.price_old)+'
';
item += '
'+setFormatMoney(value.price)+'
';
item += '
';
}else{
item += '
'+setFormatMoney(value.price)+'
';
}
if(elDia >= 16 && elDia <= 17 && elMes === 11 && elAno === 2022){
item += '
';
item += '
';
}
if(Tot_Env >= 1800){
item += '
o hasta 18 pagos fijos de '+setFormatMoneyMens(Mensualidad)+'
';
};
if(value.only_store=="yes"){
item += '
Agregar al carrito ';
}else{
item += '
Agregar al carrito ';
}
item += '
';
}
$("#listProductsRelated").html(item);
// loadCartOFF();
// var parentwidth = $("#headerCartRes").width();
// $("#btnIr").width(parentwidth);
// if(banderaBannerTeflon){
// $("#headerCartTeflon").show();
// }else{
// $("#headerCartTeflon").hide();
// }
// cartDown();
}
var banderaCant = false;
var bandIdCant = "";
function changeComboCantidadCarrito(){
$(document).on('change', '.SelectCant', function (event) {
var valueCombo = $(this).val();
var idproduct= $(this).attr("itemid");
var sku = $(this).attr("sku");
var price = $(this).attr("price");
if($(this).attr("typeElement") == "product"){
var elementInput = "quantityProdCustomP-"+idproduct;
}else{
var elementInput = "quantityProdCustom-"+idproduct;
}
if (valueCombo == 'customOption') {
$(this).css({ 'display': 'none' });
$(this).prop('disabled', true);
$('#' + elementInput).css({ 'display': 'flex' });
$('#' + elementInput).css({ 'border': '2px solid blue' });
$('#' + elementInput).css({ 'border-radius': '4px' });
$('#' + elementInput).prop('disabled', false);
$('#' + elementInput).val('');
banderaCant = true;
bandIdCant = elementInput;
return;
} else {
if($(this).attr("typeElement") == "product"){
$(this).attr("tempcant",valueCombo) ;
$('#' + elementInput).attr("tempcant",valueCombo) ;
var valorCP = getCP();
if (valorCP !== "") {
findCP(valorCP);
}
return;
}
updateShoppingcart(idproduct, valueCombo, "quantity", sku, price);
}
});
}
function changeInputCantidadCarrito(){
// console.log(">>>>>>>> changeInputCantidadCarrito-----------");
$(document).on('blur', '.customCant', function (event) {
if($(this).attr("typeElement") == "product"){
if(!banderaCant)
{changeInputCantidadProduct($(this));}
return;
}
var valueInput = $(this).val();
var idproduct= $(this).attr("itemid");
var elementCombo = "quantityProdSelect-"+idproduct;
var tempCant = $(this).attr("tempcant");
var sku = $(this).attr("sku");
var price = $(this).attr("price");
// console.log("Valor del input: "+valueInput);
// console.log("Id del producto: "+idproduct);
// console.log("Temporal cantidad: "+tempCant);
if(valueInput == tempCant){
// console.log("No hace nada, el input y la cantidad de producto es igual");
return;
}
if (valueInput == '') {
// console.log("Input vacio, Muestra el combo y selecciona la cantidad actual del producto");
$(this).css({ 'display': 'none' });
$(this).prop('disabled', true);
$('#' + elementCombo).css({ 'display': 'flex' });
$('#' + elementCombo).prop('disabled', false);
$('#' + elementCombo).val(tempCant);
return;
}
if (valueInput <= 6) {
// console.log("Input <=6 No hace cambios en los elementos, solo ejecuta updateShoppingcart");
// $(this).css({ 'display': 'none' });
// $(this).prop('disabled', true);
// $('#' + elementCombo).css({ 'display': 'flex' });
// $('#' + elementCombo).prop('disabled', false);
// $('#' + elementCombo).val(valueInput);
updateShoppingcart(idproduct, valueInput, "quantity", sku, price);
return;
//
}
if (valueInput > 6) {
// console.log("Input > 6 No hace cambios en los elementos, solo ejecuta updateShoppingcart");
updateShoppingcart(idproduct, valueInput, "quantity", sku, price);
return;
}
});
}
function maxLengthCant(object) {
if (object.value.length > 3)
object.value = object.value.slice(0, 3)
}
function changeInputCantidadProduct(element){
// console.log(">>>>>>>> changeInputCantidadProduct-----------");
var valorCP = getCP();
if (valorCP == "" || valorCP == null) {
// console.log('No hay CP no hace la consulta de Stock');
return;
}
var valueInput = element.val();
var idproduct= element.attr("itemid");
var tempCant = element.attr("tempcant");
if(element.attr("typeElement") == "product"){
var elementCombo = "quantityProdSelectP-"+idproduct;
}else{
var elementCombo = "quantityProdSelect-"+idproduct;
}
// console.log("Value input: "+valueInput );
// console.log("idproduct: >"+idproduct+"<" );
// console.log("elementCombo: "+elementCombo );
// console.log("tempCant: "+tempCant );
if (valueInput == '') {
if (tempCant <= 6) {
// console.log("Entra aqui <=6 ");
element.css({ 'display': 'none' });
element.prop('disabled', true);
$('#' + elementCombo).css({ 'display': 'flex' });
$('#' + elementCombo).prop('disabled', false);
$('#' + elementCombo).val(tempCant);
}else{
// console.log("Entra aqui else ");
element.val(tempCant);
}
}else{
if (valueInput <= 6) {
element.css({ 'display': 'none' });
element.prop('disabled', true);
$('#' + elementCombo).css({ 'display': 'flex' });
$('#' + elementCombo).prop('disabled', false);
$('#' + elementCombo).val(valueInput);
element.attr("tempcant",valueInput) ;
$('#' + elementCombo).attr("tempcant",valueInput) ;
}else{
element.css({ 'border': '' });
element.css({ 'border-radius': '' });
element.attr("tempcant",valueInput) ;
$('#' + elementCombo).attr("tempcant",valueInput) ;
}
findCP(valorCP);
return;
}
// var valorCP = getCP();
// if (valorCP !== "") {
// // console.log("Entra a buscar Carrito");
// //buscarCarrito();
// }
// return;
}
// Función para alertar faltantes en TOTALES de carrito
function checkMissing() {
/*
var currentdate = new Date();
var elAno = currentdate.getFullYear();
var elMes = (currentdate.getMonth()+1);
var elDia = currentdate.getDate();
if(elDia >= 23 && elDia <= 31 && elMes === 05 && elAno === 2022){
var subtotal = $("table.resumen #total").html();
subtotal = subtotal.replace(/[MXN $ ,]/gi, '');
subtotal = subtotal * 1;
let faltante = (((Math.floor(subtotal / 10000)) + 1) * 10000) - subtotal;
console.log("subT= "+faltante);
if(subtotal > 0){
$("#bnrCart").show();
$("#bnrCart").html("
Te faltan sólo $" + faltante.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN para obtener otros $1,000 MXN de descuento, ¡Sigue llenando tu carrito!
");
}
*/
/*
if(subtotal > 8000 && subtotal < cupon1){
var res = cupon1 - subtotal;
$("#missing").html("$ " + res.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + " MXN");
$("#missing-cupon").html(cupon1.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"));
}
*/
var subtotal = $("table.resumen #td_subtotal").html();
subtotal = subtotal.replace(/[MXN $ ,]/gi, '');
subtotal = subtotal * 1;
let faltante = (((Math.floor(subtotal / 3000)) + 1) * 3000) - subtotal;
/*let descuento = (((Math.floor(subtotal / 3000)) + 1) * 500)*/
/*
console.log("Division= "+subtotal/3000);
console.log("Division con Math= "+Math.floor(subtotal/3000));
console.log("Descuento Previo= "+descuento);
console.log("subTotal= "+subtotal);
console.log("Faltante= "+faltante);
console.log("Descuento Posterior= "+descuento);
if(subtotal > 0){
$("#bnrCart").hide();
$("#bnrCart").html("
¡Sigue llenando tu carrito! Agrega $"+faltante.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") +" a tu órden y ahorra $500 extra.
");
}
*/
/*
if(subtotal > 0){
$("#bnrCart").show();
if(subtotal < 3000){
//$("#bnrCart").html("
¡Sigue llenando tu carrito! Ahorra $500 agregando $"+ faltante.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") +" adicionales
");
}
if(subtotal >=10000 && subtotal < 20000){
//$("#bnrCart").html("
¡Sigue llenando tu carrito! Ahorra $3,000 comprando más de $20,000
");
}
if(subtotal >=20000 && subtotal < 35000){
//$("#bnrCart").html("
¡Sigue llenando tu carrito! Ahorra $6,000 comprando más de $35,000
");
}
if(subtotal >=35000 ){
//$("#bnrCart").html("
¡Sigue llenando tu carrito! Ahorra $10,000 comprando más de $50,000
");
}
}*/
}
//funcion para pixel de facebook addtocart
function FBaddtocart(name, cat, id, quant, val){
fbq('track', 'AddToCart', {
content_name: name,
content_category: cat,
content_ids: id,
content_type: 'product',
quantity_product: quant,
value: val,
currency: 'MXN'
});
}
//funcion para cargar imagen recomendada
function loadIMGReco(){
$(function(){
$('.dropdown').hover(function() {
var name = $(this).data("name");
var src = $(this).data("src");
var image = new Image();
image.src = src;
$('#imgRelacionada-'+name).append(image);
},
function() {
// console.log("sale")
$('.submenu-img img').remove();
});
});
}
function limpiarSLUGname(text){
var text = text.toLowerCase(); // a minusculas
text = text.replace('/ ', '-');
text = text.replace(/[áàäâå]/, 'a');
text = text.replace(/[éèëê]/, 'e');
text = text.replace(/[íìïî]/, 'i');
text = text.replace(/[óòöô]/, 'o');
text = text.replace(/[úùüû]/, 'u');
text = text.replace(/[ýÿ]/, 'y');
text = text.replace(/[ñ]/, 'n');
text = text.replace(/[ç]/, 'c');
text = text.replace(/ /g, "-");
text = text.replace(/\//g, "-");
return text;
}
function checkCuponPromo(couponText){
if(COUPON_PROMO_2.code == ""){return false;}
couponText = couponText.toUpperCase();
return couponText == COUPON_PROMO_2.code;
}
flagCurrentAmountCoupon = 4000;
function validCurrentCupon(totalProducts){
var flagPivote = (Math.trunc(totalProducts / flagCurrentAmountCoupon)) + 1;
var extraAmount = (flagPivote * flagCurrentAmountCoupon) - totalProducts;
var textMsg = "
¡Sigue llenando tu carrito! Agrega $"+extraAmount.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") +" a tu órden y ahorra $600 extra.
";
$("#bnrCart").html(textMsg);
$("#bnrCart").hide();
}
/*
//function initBarRatingFeatured() {
function initBarRating() {
$('.reviews-slct').each(function () {
var sc = $(this).attr("score");
var id = $(this).attr("id");
setBarRating(id, sc);
console.log("id = "+id+" score = "+sc);
});
}
function setBarRating(id, score) {
var stars = 0;
if (score != 0) {
stars = score * 5 / 100;
}
$('#' + id).barrating({
theme: 'fontawesome-stars-o',
readonly: true,
emptyValue: 0,
initialRating: stars
});
}
*/