$(document).ready(function() {
$(".accordion").accordion({
heightStyle: "content"
});
//auto complete for product
$(".txt_search").each(function(index, el) {
$(".txt_search").keyup(function() {
var values = $(this).val();
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=getSearchJsonDiv123",
data: {
val: values
},
beforeSend: function() {},
success: function(data) {
$(".col3_main").hide();
$(".col3_top").hide();
$(".col6").hide();
$(".col1_right section").hide();
$(".col1_right .container-fluid").hide();
$(".add_to_cart_main_pic_slide").hide();
$(".add_to_cart_main_pic_responsive").hide();
$(".add_product_to_cart").hide();
$(".tabs_main_side").hide();
$(".col3_main").hide();
$(".col2").hide();
$(".hideall").hide();
$(".col7").show();
$(".col1_right_des").hide();
$(".inner_banner").hide();
$(".col4_heading_side").show();
$(".col3_main_all").html(data);
console.log(data);
linknew(values);
}
});
});
});
$(".txt_search1").each(function(index, el) {
$(".txt_search1").keyup(function() {
var values = $(this).val();
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=getSearchJsonDiv123",
data: {
val: values
},
beforeSend: function() {},
success: function(data) {
$(".col3_main").hide();
$(".col3_top").hide();
$(".col6").hide();
$(".col1_right section").hide();
$(".col1_right .container-fluid").hide();
$(".add_to_cart_main_pic_slide").hide();
$(".add_to_cart_main_pic_responsive").hide();
$(".add_product_to_cart").hide();
$(".tabs_main_side").hide();
$(".col3_main").hide();
$(".col2").hide();
$(".hideall").hide();
$(".col7").show();
$(".col1_right_des").hide();
$(".inner_banner").hide();
$(".col4_heading_side").show();
$(".col3_main_all").html(data);
linknew(values);
}
});
});
});
//auto complete for product
$(".txt_search_cat").each(function(index, el) {
$(".txt_search_cat").keyup(function() {
var values = $(this).val();
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=getSearchJsontxt_search_cat",
data: {
val: values
},
beforeSend: function() {},
success: function(data) {
$(".col3_main").hide();
$(".col3_top").hide();
$(".col6").hide();
$(".col1_right section").hide();
$(".col1_right .container-fluid").hide();
$(".add_to_cart_main_pic_slide").hide();
$(".add_to_cart_main_pic_responsive").hide();
$(".add_product_to_cart").hide();
$(".tabs_main_side").hide();
$(".col3_main").hide();
$(".col2").hide();
$(".hideall").hide();
$(".col7").show();
$(".col1_right_des").hide();
$(".inner_banner").hide();
$(".col4_heading_side").show();
$(".col3_main_all").html(data);
linknew(values);
}
});
});
});
});
function productSearch() {
//not in use,, built for get product for search
srch = $('.txt_search').val();
$.ajax({
type: 'GET',
url: 'https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=getSearchJson',
data: {
val: srch
}
}).done(function(data) {
if (data == '[]') {
productSearchAutoComplete(data);
} else {
productSearchAutoComplete(data);
}
});
}
function productSearchAutoComplete(data) {
//products load after country select
var availableTags = eval(data);
$(".txt_search").autocomplete({
source: function(request, response) {
$.ajax({
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=getSearchJson",
dataType: "POST",
data: {
val: $('.txt_search').val()
},
success: function(data) {
response(data);
}
});
},
minLength: 0,
select: function(event, ui) {
$('.txt_search').val(ui.item.label);
}
}).on('focus : click', function(event) {
$(this).autocomplete("search", "");
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("
")
.data("item.autocomplete", item)
.css({
"margin": "1px 0",
"height": "70px",
"padding": "5px"
})
.append("" +
"
" +
"
" +
"
" +
"
" + item.label + "
" + item.oldPrice + "
" + item.newPrice + "
" +
"
")
.appendTo(ul);
};
}
// new //
function linknew(id) {
catP = getParam('cat');
search = getParam('s');
var params = "";
if (catP == "" && search == "") {
params = "https://sharkspeed.se/search.php?s=" + id;
} else if (catP != "" && search == "") {
params = "cat=" + catP + "&search=" + id;
} else if (catP == "" && search != "") {
params = "https://sharkspeed.se/search.php?s=" + id;
}
history.pushState(null, "search", params);
}
// new end //
//Create Link
function link(id) {
catP = getParam('cat');
search = getParam('s');
var params = "";
if (catP == "" && search == "") {
params = "product=" + id;
} else if (catP != "" && search == "") {
params = "cat=" + catP + "&product=" + id;
} else if (catP == "" && search != "") {
params = "s=" + search + "&product=" + id;
}
history.pushState(null, "Product ", "?" + params);
}
function blankLink() {
catP = getParam('cat');
search = getParam('s');
var params = "";
if (catP == "" && search == "") {
params = ""
} else if (catP != "" && search == "") {
params = "cat=" + catP;
} else if (catP == "" && search != "") {
params = "s=" + search;
}
history.pushState(null, "Product ", "?" + params);
}
//get Parameter Value
function getParam(sname) {
var params = location.search.substr(location.search.indexOf("?") + 1);
var sval = "";
params = params.split("&");
// split param and value into individual pieces
for (var i = 0; i < params.length; i++) {
temp = params[i].split("=");
if ([temp[0]] == sname) {
sval = temp[1];
}
}
return sval;
}
$(document).ready(function() {
loadId = getParam('product');
if (isNaN(loadId) || loadId == '') {} else {
quickView(false, loadId);
}
$(document).on('click', '.left_image_plus_divTT', function() {
//remove tt to work like other website
href = $(this).attr('data-href');
$('.openProductImage1 img').attr('src', href);
$('.openProductImage1').css('display', 'block');
$('body').css('overflow', 'hidden');
});
$('.openProductImage1 .close-btn').click(function() {
$('.openProductImage1').css('display', 'none');
$('body').css('overflow', 'auto');
});
function loadProduct(ths, productId) {
//first use in happi...
cat = getParam('cat');
url = 'https://sharkspeed.se/products_detail_ajax.php?cat=' + cat;
$(".product_detailJs").stop().slideUp(20);
var thes = $("#detail_" + productId).closest('.pro_box_single');
$("#detail_" + productId).stop().slideDown("slow");
link(productId);
if ($("#detail_" + productId).hasClass('loaded')) {
scrollProduct(productId);
} else {
$.ajax({
url: url,
type: "POST",
data: {
id: productId
}
}).done(function(response) {
$("#detail_" + productId).html(response);
var left = thes.offset().left;
var res = 141.5 - left;
var wid = document.body.offsetWidth;
$("#detail_" + productId).find(".dive_short_details").css('left', -left);
$("#detail_" + productId).find(".dive_short_details").css('width', wid);
$("#detail_" + productId).addClass('loaded');
scrollProduct(productId);
});
}
}
function scrollProduct(productId) {
$('html, body').animate({
scrollTop: $('#p' + productId).offset().top - 150
}, 1500);
}
$(document).on('click', ".show_details", function() {
productId = $(this).attr('data-id');
loadProduct(this, productId);
});
$(document).on('click', '.close_details_div', function() {
$(".product_detailJs").hide("slow");
blankLink();
});
//use this process for click on next to show next product quick view..
$(document).on('click', '.details_right_btn', function() {
serialId = parseInt($(this).closest('.product_detailJs').attr('data-serial'));
serialId = eval(serialId + 1);
productId = $('.product_serial_' + serialId).attr('data-id');
if (isNaN(productId)) {
serialId = 1;
productId = $('.product_serial_' + serialId).attr('data-id');
}
loadProduct(this, productId);
});
$(document).on('click', '.details_left_btn', function() {
serialId = parseInt($(this).closest('.product_detailJs').attr('data-serial'));
serialId = eval(serialId - 1);
productId = $('.product_serial_' + serialId).attr('data-id');
if (isNaN(productId)) {
serialId = 1;
productId = $('.product_serial_' + serialId).attr('data-id');
}
loadProduct(this, productId);
});
$('#paymentOptionNext').on('click', function(event) {
event.preventDefault();
select_change_payment();
});
$('#overlay_order_container').on('click', '#paymentOptionNext', function(event) {
select_change_payment();
});
});
function select_change_payment() {
if ($('.paymentOptionRadio').is(":checked")) {
paymentOption = $('.paymentOptionRadio:checked').val();
//0 cash on delivery
//1 paypal
//2 klarna
//5 pason
//6 GiftCard
//7 2 checkout
// 10 Cembra
if (paymentOption == '0' || paymentOption == '1' || paymentOption == '5' || paymentOption == '8' || paymentOption == '10') {
$("#cartLoading").slideDown(500);
inv = $('#invoiceId').val();
$.ajax({
type: "POST",
url: "https://sharkspeed.se/cartContinue.php?inv=" + inv + "&paymentOption=" + paymentOption
}).done(function(data) {
$("#cartLoading").slideUp(500);
$("#cartContinue").show();
$("#cartContinue").html(data);
// hide payment div
$('#first_option').next('.area_form3').hide('slow');
$('#first_option').find('.d_tick').show();
add_payment_method_price();
});
return true;
} else if (paymentOption == '2') {
inv = $('#invoiceId').val();
url = 'https://sharkspeed.se/klarna.php?ajax=1&inv=' + inv;
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: url
}).done(function(data) {
$("#cartLoading").slideUp(500);
$("#cartContinue").show();
$("#cartContinue").html(data);
add_payment_method_price();
});
return true;
} else if (paymentOption == '9') {
inv = $('#invoiceId').val();
url = 'https://sharkspeed.se/klarnaPayment.php?ajax=1&inv=' + inv;
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: url
}).done(function(data) {
$("#cartLoading").slideUp(500);
$("#cartContinue").show();
$("#cartContinue").html(data);
add_payment_method_price();
});
return true;
} else {
$("#cartContinue").html("");
add_payment_method_price();
}
};
}
function quickView(ths, productId) {
//call productQuickViewModel() in end of footer file..
//link updating is stop due to some parametrs are remove
var url = "https://sharkspeed.se/quickView.php?pId=" + productId;
$("#frameProductQuickView").html(loading_progress()).load(url);
$("#productQuickView").modal('show');
}
function tax2(total) {
tax = eval(total * 25 / 100);
$('.pGrandtax').text(tax);
}
function productColorPriceUpdate(pId, colorId) {
// check if this color select n again click nothing happen
if ($('.colorDiv_' + pId + '.colorId_' + colorId + ":checked").hasClass('colorChecked')) {
} else {
var color = $('.colorDiv_' + pId + '.colorId_' + colorId);
inventoryLimit = $('#deatilStockCheck_' + pId).val();
//Active color size
scalesIds = color.attr('data-scales');
if (inventoryLimit == '1') {
//hide product size if no stock
$('#p' + pId).find('.size_in_divs.sizeDiv_' + pId).addClass("no_stock");
}
var product_div = $('#p' + pId);
product_div.find(scalesIds).show();
product_div.find(scalesIds).removeClass("no_stock");
product_div.find('.sizeId_-1').show(); //custom size
$('.sizeSelect_' + pId).prop('checked', false);
$('#stock_' + pId).html("");
$('.colorDiv_' + pId).removeClass('colorChecked');
color.addClass('colorChecked');
//make AddToCart Function to reset
$('.AddToCart_' + pId).attr('data-scaleSelect', '0');
$('.sizeChecked').removeClass('sizeChecked');
var price = color.attr("data-price");
//if scale not allow in project then show inventory of color,
colorInv = color.attr("data-colorinv");
//set old price to default, this is helpful when size has different price
setOldDefaultPrice(pId);
if (colorInv != '') {
stockPrint(pId, colorInv);
}
plusPrice(price, pId);
}
}
function out_of_stock_trigger(pId, colorId, scaleId, storeId) {
var stock_trigger = $("#StockSubscription");
stock_trigger.find('.out_of_stock.color_id').val(colorId);
stock_trigger.find('.out_of_stock.scale_id').val(scaleId);
stock_trigger.find('.out_of_stock.store_id').val(storeId);
stock_trigger.modal('show');
}
function out_of_checkout_trigger(invId) {
console.log("ghygjjhjgh");
var checkout_trigger = $("#CheckoutSubscription");
checkout_trigger.find('.out_of_cart.invId').val(invId);
checkout_trigger.modal('show');
}
function setOldDefaultPrice(pId) {
currency = $('#currency_' + pId);
defaultPrice = currency.attr('data-defaultprice');
$('.productOldPrice_' + pId).text(defaultPrice);
}
function stockPrint(pId, data) {
if (!data) {
// no data, just print, give default value of 1, this is for the no stock checking
$('#hidden_stock_' + pId).val(1);
$('#stock_' + pId).html(" ");
return false;
}
if (!pId || !data) {
return false;
}
data_ = $.parseJSON(data);
data = data_.qty;
location_ = data_.location_;
if (data <= 0 || isNaN(data)) {
data = 0;
}
$('#hidden_stock_' + pId).val(data);
$('#stock_' + pId).html(" ");
var hasCustomQty = $('.addByQty_hidden_' + pId).val();
var customQty = '';
if (hasCustomQty == '1') {
if (data > 0) {
$('.addByQty_' + pId).attr("max", data);
}
}
}
function productRealPrice(pId) {
currency = $('#currency_' + pId);
realPrice = parseFloat(currency.attr('data-defaultprice'));
return realPrice;
}
function productDiscountFormat(pId) {
currency = $('#currency_' + pId);
discountFormat = currency.attr('data-discountformat');
if (discountFormat == "" || isNaN(discountFormat) || discountFormat == undefined) {
return false;
}
return discountFormat;
}
function productDiscountPrice(pId) {
currency = $('#currency_' + pId);
discountP = parseFloat(currency.attr('data-discountp'));
if (discountP == "" || isNaN(discountP) || discountP == undefined) {
return 0;
}
return discountP;
}
function plusPrice(price, pId) {
price1 = productRealPrice(pId);
total = eval(price1 + parseFloat(price));
currency = $('#currency_' + pId);
discountFormat = currency.attr('data-discountformat');
discountP = parseFloat(currency.attr('data-discountp'));
discount = discountCalculation(total, discountP, discountFormat);
$('.productOldPrice_' + pId).text(total);
$('.productPrice_' + pId).text(discount);
}
function minusPrice(price, pId) {
price1 = productRealPrice(pId);
price1 = eval(price1 - parseFloat(price));
$('.productPrice_' + pId).text(price1);
}
function plusOldPrice(price, pId) {
price1 = productDiscountPrice(pId);
price1 = eval(price1 + parseFloat(price));
$('.productPrice_' + pId).text(price1);
}
function minusOldPrice(price, pId) {
price1 = productDiscountPrice(pId);
price1 = eval(price1 - parseFloat(price));
$('.productPrice_' + pId).text(price1);
}
function productPriceUpdate(pId, dealPro = false) {
console.log(pId);
setTimeout(function() {
updatePrice(pId)
if (dealPro) {}
}, 400);
}
function productPriceUpdateNew(pId, cId) {
//use for scale price update
setTimeout(function() {
updatePriceNew(pId, cId)
}, 400);
}
function updatePriceNew(pId, cartId) {
console.log("updatePriceNew");
storeId = $('#store_' + pId).val();
hasScale = $('#hasScale_' + pId).val();
size = $('.sizeSelect_' + pId + ":checked");
scaleId = size.attr('data-id');
if (hasScale == '0') {
scaleId = '0';
}
hasColor = $('#hasColor_' + pId).val();
color = $('.colorSelect_' + pId + ':checked');
colorId = color.attr('data-id');
if (hasColor == '0') {
colorId = '0';
}
console.log('cartId : ' + cartId);
console.log('pId : ' + pId);
console.log('storeId : ' + storeId);
console.log('scaleId : ' + scaleId);
console.log('colorId : ' + colorId);
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=sizeCartUpdate";
$.ajax({
type: "POST",
url: url,
data: {
cartId: cartId,
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId
}
}).done(function(data) {
cart_load_from_side(true);
});
}
function updatePrice(pId) {
console.log("updatePrice");
hasColor = $('#hasColor_' + pId).val();
hasScale = $('#hasScale_' + pId).val();
if ($('.sizeSelect_' + pId).is(":checked")) {
size = $('.sizeSelect_' + pId + ":checked");
color = $('.colorSelect_' + pId + ':checked');
currency = $('#currency_' + pId);
sizeId = size.attr('data-id');
//check if size already select
if ($('.sizeId2_' + sizeId + ":checked").hasClass('sizeChecked')) {
} else {
$('.sizeSelect_' + pId).removeClass('sizeChecked');
$('.sizeId2_' + sizeId).addClass('sizeChecked');
sizeId = size.attr('data-id');
colorId = color.attr('data-id');
colorPrice = parseFloat(color.attr('data-price'));
if (hasColor == '0') {
colorPrice = 0;
colorId = 0;
}
sizePrice = parseFloat(size.attr('data-price'));
if (hasScale == '0') {
sizePrice = 0;
sizeId = 0;
}
clearancePrice = parseFloat(size.attr('data-clearance-price'));
realPrice = parseFloat(currency.attr('data-defaultprice'));
discountFormat = currency.attr('data-discountformat');
if(clearancePrice > 0){
discountP = clearancePrice;
}else{
discountP = parseFloat(size.attr('data-discountp'));
}
total = eval(realPrice + colorPrice + sizePrice);
discount = discountCalculation(total, discountP, discountFormat);
discountPercentage = discountPercentageCalculation(total, discountP, discountFormat)
console.log(total, discount, discountPercentage)
if (discountPercentage !== undefined && discountPercentage != NaN) {
$(`.productPrice_${pId}_dscntPrice`).text(`${discountPercentage} %`);
}
if (total !== undefined && total != NaN) {
$(`.productPrice_${pId}_actPrice`).text(`${total}`);
}
if (discount !== undefined && discount != NaN) {
if(clearancePrice > 0){
$(`.productPrice_${pId}_disPrice`).text(`${clearancePrice}`);
} else {
$(`.productPrice_${pId}_disPrice`).text(`${discountP}`);
}
}
$('.productOldPrice_' + pId).text(total);
$('.productPrice_' + pId).text(discount);
productStockCheck(pId, sizeId, colorId);
console.warn(1);
}
}
}
function applyCoupon() {
coupon = $('#couponCode').val();
if (coupon != '') {
location.replace('cart?coupon=' + coupon);
}
}
function applyGiftCard() {
giftCard = $('#applyGiftCard').val();
if (giftCard != '') {
location.replace('cart?giftCard=' + giftCard);
}
}
function applyGiftCardd() {
giftCard = $('#applyGiftCard').val();
if (giftCard != '') {
location.replace('cart?giftCard=' + giftCard);
}
}
$(document).ready(function() {
$('#couponCode').keypress(function(e) {
var charCode = e.charCode || e.keyCode || e.which;
if (charCode == 13) {
applyCoupon();
return false;
}
});
$('#giftCartId_input').keypress(function(e) {
var charCode = e.charCode || e.keyCode || e.which;
if (charCode == 13) {
applyGiftCard();
return false;
}
});
});
function discountPercentageCalculation(total, discountP, discountFormat) {
var discount = '';
if (discountFormat == 'percent') {
discount = discountP;
return discount;
}
discount = eval(discountP / total) * 100;
discount = Math.ceil(discount);
return discount;
}
function discountCalculation(total, discountP, discountFormat) {
var discount = '';
if (discountFormat != '') {
if (discountFormat == 'price') {
discount = eval(total - discountP);
} else if (discountFormat == 'percent') {
discount = eval(total * discountP) / 100;
discount = eval(total - discount);
}
} else {
discount = total;
}
discount = Math.ceil(discount);
console.log(total, discountP, discountFormat)
return discount;
}
function discountCalculationCart(total, discountP, discountFormat, qty) {
var discount = '';
if (discountFormat != '') {
if (discountFormat == 'price') {
pricT = parseFloat(eval(discountP * qty));
discount = pricT;
} else if (discountFormat == 'percent') {
discount = eval(total * discountP) / 100;
discount = Math.round(discount * 100) / 100;
}
} else {
discount = 0;
}
discount = eval(discount / qty);
discount = Math.floor(discount);
discount = eval(discount * qty);
return discount;
}
function customFormAddProductFields(pId) {
hasColor = $('#hasColor_' + pId).val();
color = $('.colorSelect_' + pId + ':checked');
colorId = color.attr('data-id');
if (hasColor == '0') {
colorId = '0';
}
storeId = $('#store_' + pId).val();
currency = $('#currency_' + pId);
$('.customColor_' + pId).val(colorId);
$('.customStore_' + pId).val(storeId);
}
function customFormSubmit(ths, pId) {
if ($("#custom_check").is(":checked")) {
console.log("THE CHECK BOX IS CHECKED");
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCartCustom",
data: $('#customForm_' + pId).serialize()
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1' || data == '') {
updateCartNoOnWeb();
cartSmallProduct();
afterAddToCart_show_goToCart_option();
} else {
jAlertifyAlert(data);
}
});
} else {
$('.checkbox').parents('div.form-group').css({
'background-color': 'rgb(211, 74, 70)',
'border': '1px solid'
});
};
return false;
}
productStockCheck = function(pId, scaleId, colorId) {
if (scaleId == '-1') {
$('.AddToCart_' + pId).hide(100);
$('.AddToCart_' + pId).removeAttr("disabled", "disabled");
$('.AddToCart_' + pId).attr("data-scaleSelect", "1");
stockPrint(pId, '');
customFormAddProductFields(pId);
console.warn(2);
return true;
}
$('.AddToCart_' + pId).show(500);
inventoryLimit = $('#deatilStockCheck_' + pId).val();
if (inventoryLimit == '0') {
$('.AddToCart_' + pId).removeAttr("disabled", "disabled");
$('.AddToCart_' + pId).attr("data-scaleSelect", "1");
stockPrint(pId, "");
console.warn(3);
return true;
}
storeId = $('#store_' + pId).val();
$('#stock_' + pId).html(loading_progress());
$.ajax({
type: "POST",
url: "myAdmin/stock/stock_ajax.php?page=countCurrentQTY",
data: {
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId,
loadFromWeb: '1'
}
}).done(function(data) {
stockPrint(pId, data);
if (data == 0) {
$('.AddToCart_' + pId).attr("disabled", "disabled");
$('.AddToCart_' + pId).hide();
$('.AddToCart_' + pId).attr("data-scaleSelect", "0");
} else {
$('.AddToCart_' + pId).removeAttr("disabled", "disabled");
$('.AddToCart_' + pId).attr("data-scaleSelect", "1");
}
});
console.warn(4);
}
var checkOutOfferAddtoCart = false; // use this var for check is client add to cart checkout offer or not
var doNotForgetOfferAddtoCart = false; // use this var for check is client add to cart checkout offer or not
function addToCart(ths, pId, show_modal = false, checkout = false) {
let showModal = show_modal == pId ? 'popUpNew' : "";
show_modal = ((typeof(show_modal) == 'undefined' || show_modal == false) ? false : true);
hasColor = $('#hasColor_' + pId).val();
hasScale = $('#hasScale_' + pId).val();
salePrice = $('#salePrice_' + pId).val();
// For Special Sale Product on Invoice
saleProductPrice = (typeof(salePrice) == 'undefined' ? '' : salePrice);
console.log(saleProductPrice + 'dsss');
scaleSelect = $(ths).attr('data-scaleSelect');
if ((scaleSelect == 0 || scaleSelect == '0' || isNaN(scaleSelect)) && hasScale == '1' && hasColor == '1') {
//jAlertifyAlert("Välj färg och storlek!");
}
if (hasColor != 0 || hasScale != 0) {
console.log('has color Or has size');
if (!$("input[name='sizeSelect_" + pId + "']:checked").val() || !$("input[name='sizeSelect_" + pId + "']:checked").val()) {
console.log('dropdown not selected : ' + pId);
jAlertifyAlert("Välj Storlek eller/och Färg för att gå vidare
");
return false;
}
}
var hasCustomQty = $('.addByQty_hidden_' + pId).val();
var customQty = '';
if (hasCustomQty == '1') {
customQty = $('.addByQty_' + pId).val();
var qtyMax = parseFloat($('.addByQty_' + pId).attr("max"));
if (customQty > qtyMax) {
jAlertifyAlert("Product exced Stock qty, max value is : " + qtyMax + "
");
return false;
}
if (customQty >= '1' || customQty >= 1) {
//ok
} else {
jAlertifyAlert("Ange antal
");
$('.addByQty_' + pId).focus();
return false;
}
}
size = $('.sizeSelect_' + pId + ":checked");
color = $('.colorSelect_' + pId + ':checked');
currency = $('#currency_' + pId);
scaleId = size.attr('data-id');
scaleName = size.val();
if (hasScale == '0') {
scaleId = '0';
}
colorId = color.attr('data-id');
if (hasColor == '0') {
colorId = '0';
}
storeId = $('#store_' + pId).val();
console.log('scaleID : ' + scaleId);
console.log('colorId : ' + colorId);
hasFreePro_ = $('#hasFreePro_' + pId).val();
if (0 == '1' || hasFreePro_ == '1') {
//Out of stock qty trigger
qty = $('#hidden_stock_' + pId).val();
stock_ch = '1';
} else {
//Out of stock qty trigger
qty = $('#hidden_stock_' + pId).val();
stock_ch = '';
}
if (qty <= 0 && stock_ch == '1') {
out_of_stock_trigger(pId, colorId, scaleId, storeId);
return false;
}
// Hide Do Not Offer Popup
// var donot = $('#donotoffer_'+pId).val();
// if(donot > 0){
// $('.pop_side').css({ display: 'none' });
// }
productPriceUpdate();
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCart";
if ($("#checkout_" + pId).val() == pId) {
checkOutOfferAddtoCart = true;
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCart&checkout";
}
if ($("#donotoffer_" + pId).val() == pId) {
doNotForgetOfferAddtoCart = true;
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCart&donotForget";
}
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled != 1) {
$("#cartLoading").slideDown(500);
} else {
$("#cartLoading").slideDown(500);
$('.overlay').show();
$('#overlay_container').show();
/* show the overlay */
if (showModal != 'popUpNew') {
$("#cart_side").animate({
"top": "50%"
}, "fast", function() {
/* stuff to do after animation is complete */
});
}
}
data1 = {
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId,
customQty: customQty,
salePrice: saleProductPrice,
scaleName: scaleName
};
$.ajax({
type: "POST",
url: url,
data: {
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId,
customQty: customQty,
salePrice: saleProductPrice,
scaleName: scaleName
}
}).done(function(data) {
var parsed_data = JSON.parse(data);
var popup = $('.pop_slide_main').length;
if (popup == 0) {
$('.pop_side').hide();
}
if (parsed_data.status == '1' || parsed_data.status == '') {
if (showModal == 'popUpNew') {
$(".newcart_popup").addClass('newcart_popup_');
if (parsed_data.forgetPopup != undefined || parsed_data.forgetPopup == '') {
$(".newcart_popup .inner_popup2").html(parsed_data.forgetPopup);
$('.popup_btn2').click(function() {
$(".newcart_popup").removeClass('newcart_popup_');
cart_load_from_side();
});
}
cart_load_from_side2();
} else {
$(".newcart_popup").removeClass('newcart_popup_');
if (cart_load_from_side_enabled == 1 && !checkout) {
if (parsed_data.donotForget != '' && !checkout) {
}
cart_load_from_side();
if (show_modal) {
$("#cartLoading").slideUp(500);
if (checkout) {
cart_load_from_side_submit()
} else {}
};
} else {
$("#cartLoading").slideUp(500);
if (checkout) {
cart_load_from_side_submit()
} else {
cart_load_from_side_submit()
}
}
updateCartNoOnWeb();
cartSmallProduct();
}
} else {
jAlertifyAlert(data);
}
});
}
function donot_addToCart(ths, pId, show_modal) {
show_modal = (typeof(show_modal) == 'undefined' ? false : true);
hasColor = $('#hasColor_' + pId).val();
hasScale = $('#hasScale_' + pId).val();
salePrice = $('#salePrice_' + pId).val();
// For Special Sale Product on Invoice
saleProductPrice = (typeof(salePrice) == 'undefined' ? '' : salePrice);
scaleSelect = $(ths).attr('data-scaleSelect');
if ((scaleSelect == 0 || scaleSelect == '0' || isNaN(scaleSelect)) && hasScale == '1' && hasColor == '1') {
//jAlertifyAlert("Välj färg och storlek!");
}
if (hasColor != 0 || hasScale != 0) {
console.log('has color Or has size');
if (!$("input[name='sizeSelect_" + pId + "']:checked").val() || !$("input[name='sizeSelect_" + pId + "']:checked").val()) {
console.log('dropdown not selected : ' + pId);
jAlertifyAlert("Välj Storlek eller/och Färg för att gå vidare
");
return false;
}
}
var hasCustomQty = $('.addByQty_hidden_' + pId).val();
var customQty = '';
if (hasCustomQty == '1') {
customQty = $('.addByQty_' + pId).val();
var qtyMax = parseFloat($('.addByQty_' + pId).attr("max"));
if (customQty > qtyMax) {
jAlertifyAlert("Product exced Stock qty, max value is : " + qtyMax + "
");
return false;
}
if (customQty >= '1' || customQty >= 1) {
//ok
} else {
jAlertifyAlert("Ange antal
");
$('.addByQty_' + pId).focus();
return false;
}
}
size = $('.sizeSelect_' + pId + ":checked");
color = $('.colorSelect_' + pId + ':checked');
currency = $('#currency_' + pId);
scaleId = size.attr('data-id');
if (hasScale == '0') {
scaleId = '0';
}
colorId = color.attr('data-id');
if (hasColor == '0') {
colorId = '0';
}
storeId = $('#store_' + pId).val();
console.log('scaleID : ' + scaleId);
console.log('colorId : ' + colorId);
//Out of stock qty trigger
qty = $('#hidden_stock_' + pId).val();
stock_ch = '0';
if (qty <= 0 && stock_ch == '1') {
out_of_stock_trigger(pId, colorId, scaleId, storeId);
return false;
}
// Hide Do Not Offer Popup
// var donot = $('#donotoffer_'+pId).val();
// if(donot > 0){
// $('.pop_side').css({ display: 'none' });
// }
productPriceUpdate();
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCart";
if ($("#checkout_" + pId).val() == pId) {
checkOutOfferAddtoCart = true;
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCart&checkout";
}
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled != 1) {
$("#cartLoading").slideDown(500);
} else {
$("#cartLoading").slideDown(500);
$('.overlay').show();
$('#overlay_container').show();
/* show the overlay */
$("#cart_side").animate({
"top": "50%"
}, "fast", function() {
/* stuff to do after animation is complete */
});
}
data1 = {
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId,
customQty: customQty,
salePrice: saleProductPrice
};
console.log('RawData : ' + data1);
$.ajax({
type: "POST",
url: url,
data: {
pId: pId,
storeID: storeId,
scaleId: scaleId,
colorId: colorId,
customQty: customQty,
salePrice: saleProductPrice
}
}).done(function(data) {
var parsed_data = JSON.parse(data);
if (parsed_data.status == '1' || parsed_data.status == '') {
if (cart_load_from_side_enabled == 1) {
if (parsed_data.donotForget != '') {
$('#doNotForgetToBuy').html(parsed_data.donotForget);
$('.pop_side').show();
donot_forget_offers_script();
}
cart_load_from_side();
if (show_modal) {
$("#cartLoading").slideUp(500);
afterAddToCart_show_goToCart_option();
};
} else {
$("#cartLoading").slideUp(500);
afterAddToCart_show_goToCart_option();
}
updateCartNoOnWeb();
cartSmallProduct();
} else {
jAlertifyAlert(data);
}
});
}
function afterAddToCart_show_goToCart_option() {
var goToCartOption = $('.goToCartOption').val();
if (goToCartOption == '1') {
$('#goToCartOptionId').modal('show');
}
}
function checkOutOffer() {
if (checkOutOfferAddtoCart == true) {
location.replace("");
return false;
} else {
return true;
}
}
function cartSmallProduct() {
var val = $('.cartSmallProduct').attr('data-value');
var val2 = $('.cartPriceAjax').attr('data-value');
var urlT = 'https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=cartSmallProduct';
if (val == 'has') {
urlT = urlT + "&product"
} else if (val2 == 'has') {
urlT = urlT + "&price"
}
if (val == 'has' || val2 == 'has') {
$('.cartSmallProduct').html(loading_progress());
$('.cartPriceAjax').html("...");
$.ajax({
type: "POST",
url: urlT,
data: {}
}).done(function(data) {
if (val == 'has') {
$('.cartSmallProduct').html(data);
} else if (val2 == 'has') {
$('.cartPriceAjax').html(data);
}
});
}
}
function addToWishList(ths, pId) {
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToWishList",
data: {
pId: pId
}
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1') {
updateWishListNoOnWeb();
}
});
}
function WishListRemove(ths, pId) {
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=RemoveToWishList",
data: {
pId: pId
}
}).done(function(data) {
$(ths).closest('.pBox').hide(500);
$("#cartLoading").slideUp(500);
if (data == '1') {
updateWishListNoOnWebMinus();
}
});
}
function updateWishListNoOnWeb() {
no = parseFloat($("#wishListItemNo").text());
no = eval(no + 1);
$("#wishListItemNo").text(no);
}
function updateWishListNoOnWebMinus() {
no = parseFloat($("#wishListItemNo").text());
no = eval(no - 1);
$("#wishListItemNo").text(no);
}
function updateCartNoOnWeb() {
no = parseFloat($(".cartItemNo").eq(0).text());
no = eval(no + 1);
$(".cartItemNo").text(no);
}
function updateCartNoOnWebMinus() {
no = parseFloat($(".cartItemNo").eq(0).text());
no = eval(no - 1);
$(".cartItemNo").text(no);
}
function updateCartNoOnWebRemove(qty) {
no = parseFloat($(".cartItemNo").eq(0).text());
no = eval(no - qty);
no = isNaN(no) ? 0 : no;
$(".cartItemNo").text(no);
}
function sumSingleProduct(cartId, qty) {
ActualPrice = $('#tr_' + cartId).attr('data-realPrice');
sum = eval(ActualPrice * qty);
sum = Math.round(sum * 100) / 100;
$('#tr_' + cartId).find('.sumProduct').text(sum);
cartDiscount(sum, cartId, qty);
}
function cartDiscount(total, cartId, qty) {
productId = $('#tr_' + cartId).attr('data-pid');
discountFormat = $('#discountFormat_' + productId).val();
discountP = parseFloat($('#discount_' + productId).val());
discount = discountCalculationCart(total, discountP, discountFormat, qty);
$('#tr_' + cartId).find('.pDiscount').text(discount);
}
function cart_page_reload() {
location.reload();
}
function addByQty(ths, cartId) {
addQty = parseInt($(".addByQty_" + cartId).val());
qtyOld = $(".addByQty_" + cartId).attr("data-prev");
qtyTotal = parseFloat($('#productTotalQty_' + cartId).val());
if (addQty > qtyTotal) {
jAlertifyAlert("Product exced Stock qty, max value is : " + qtyTotal + "
");
return false;
}
if (addQty >= '1' || addQty >= 1) {
//ok
} else {
jAlertifyAlert("Please Enter Correct Number.
");
return false;
}
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=addByQty",
data: {
cartId: cartId,
addQty: addQty
}
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1' || data == '') {
updateCartNoOnWeb();
qty = eval(addQty);
cartProductQtyUpdate(cartId, qty);
sumSingleProduct(cartId, qty);
cartSmallProduct();
buy_get_free();
cart_load_from_side(true);
} else {
jAlertifyAlert(data);
}
});
}
function addPlusToCart(ths, cartId) {
qty = parseFloat($('#tr_' + cartId).find('.pQty').text());
qtyTotal = parseFloat($('#productTotalQty_' + cartId).val());
if (qty == qtyTotal || qty > qtyTotal) {
return false;
}
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddPlusToCart",
data: {
cartId: cartId
}
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1' || data == '') {
updateCartNoOnWeb();
qty = eval(qty + 1);
cartProductQtyUpdate(cartId, qty);
sumSingleProduct(cartId, qty);
cartSmallProduct();
} else {
jAlertifyAlert(data);
}
});
}
function minusFromCart(ths, cartId) {
qty = parseFloat($('#tr_' + cartId).find('.pQty').text());
if (qty == 0 || qty == 1 || qty < 2) {
return false;
}
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=minusFromCart",
data: {
cartId: cartId
}
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1' || data == '') {
updateCartNoOnWebMinus();
qty = eval(qty - 1);
cartProductQtyUpdate(cartId, qty);
sumSingleProduct(cartId, qty);
cartSmallProduct();
} else {
jAlertifyAlert(data);
}
});
}
function cartProductRemove(ths, cartId, reload, checkout = false) {
qty = parseFloat($('#tr_' + cartId).find('.pQty').text());
reload = (typeof(reload) == 'undefined') ? true : reload;
$('.pGrandTotal,.pTotalWeight').html('Loading...');
$("#cartLoading").slideDown(500);
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=cartProductRemove",
data: {
cartId: cartId
}
}).done(function(data) {
if (data == '1' || data == '') {
if (checkout) {
$(ths).closest(".single_order").hide(500)
// after deleting submit cart subbmission form
cart_load_from_side_submit()
} else {
updateCartNoOnWebRemove(qty);
remove_div($('#tr_' + cartId), 0);
$(".tr_" + cartId).hide(500);
cartSmallProduct();
setTimeout(function() {
totalPrice();
totalWeight();
}, 1200);
}
if (reload) {
cart_page_reload();
};
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled == 1) {
var scroll_to_top = false;
cart_load_from_side(scroll_to_top);
}
$("#cartLoading").slideUp(500);
} else {
jAlertifyAlert(data);
}
});
}
function totalPrice() {
total = 0;
$('.pTotalPrice').each(function(k, v) {
price = parseFloat($(this).text());
total = eval(total + price);
});
total = Math.round(total * 100) / 100;
getShippingHightClass();
shippingFreePriceLimit(total);
total = addShippingPrice(total);
updateGiftCardPrice_onCart(total);
total = removeGiftCardPrice(total);
$('.pGrandTotal').text(total);
$('.pGrandTotal').attr('data-total', total);
tax2(total);
}
function shippingFreePriceLimit(total) {
shippingLimit = $(".shippingLimit").val();
if (total > shippingLimit) {
//free
$(".shippingPrice").val(0);
$(".shippingPriceText").text(0);
} else {
var shippingPrice = parseFloat($(".shippingPrice").val());
$(".shippingPrice").val(shippingPrice);
$(".shippingPriceText").text(shippingPrice);
}
}
function removeGiftCardPrice(total) {
var giftCardPrice = parseFloat($(".giftCard_payPrice_input").val());
if (giftCardPrice > 0) {
total = eval(total - giftCardPrice);
}
return total;
}
function updateGiftCardPrice_onCart(totalCartPrice) {
// giftcardPrice_span_cartPrice giftcardPrice_span_giftPrice
var giftCardPrice = $('.giftCard_giftPrice_input').val();
var giftPayPrice = $('.giftCard_payPrice_input').val();
var orderPrice = parseFloat(totalCartPrice); //grand total
if (orderPrice > giftCardPrice) {
orderPrice = giftCardPrice;
}
$('.giftCard_payPrice_input').val(orderPrice);
$('.giftcardPrice_span_payPrice').html(orderPrice);
}
function addShippingPrice(total) {
var shippingPrice = parseFloat($(".shippingPrice").val());
if (shippingPrice > 0) {
total = eval(total + shippingPrice);
}
return total;
}
function getShippingHightClass() {
//this will get high shipping class price.. and change shipping hidden price to new high value
shippingType = $(".shippingType").val();
if (shippingType != 'class') {
return false;
}
var shippingBigPrice = 0;
$(".shippingClass").each(function() {
price = $(this).val();
if (shippingBigPrice < price) {
shippingBigPrice = price;
}
});
$(".shippingPrice").val(shippingBigPrice);
$(".shippingPriceText").text(shippingBigPrice)
return shippingBigPrice;
}
function cartProductQtyUpdate(cartId, qty) {
$('#tr_' + cartId).find('.pQty').text(qty);
ActualPrice = $('#tr_' + cartId).attr('data-price');
total = eval(ActualPrice * qty);
total = Math.round(total * 100) / 100;
$('#tr_' + cartId).find('.pTotalPrice').text(total);
totalPrice();
pWeight(cartId, qty);
}
function cartContinue() {
$('.paymentOptionDiv').slideDown(500);
}
function pWeight(cartId, qty) {
ActualWeight = $('#tr_' + cartId).attr('data-weight');
total = eval(ActualWeight * qty);
total = Math.round(total * 100) / 100;
$('#tr_' + cartId).find('.product_weight').val(total);
$('#tr_' + cartId).find('.pWeight').text(total);
totalWeight();
}
function totalWeight() {
total = 0;
$('.product_weight').each(function(k, v) {
weight = parseFloat($(this).val());
total = eval(total + weight);
});
total = Math.round(total * 100) / 100;
$('.pTotalWeight').text(total);
$('.totalWeightInput').val(total);
}
function shippingPriceWidget() {
$('.cartSubmit1').attr('disabled', 'true');
$("#cartLoading").slideDown(500);
deliverCountry = $('#shippingWidget').val();
storeCountry = $('#storeCountryShippingWidget').val();
$.ajax({
type: "POST",
url: "myAdmin/order/order_ajax.php?page=shippingPrice",
data: {
storeCountry: storeCountry,
deliverCountry: deliverCountry
},
success: function(response) {
shippingData = ($.parseJSON(response)); // receiveing json
if (shippingData.find == '1') {
shp_int = shippingData.shp_int;
shp_weight = shippingData.shp_weight;
shp_price = shippingData.shp_price;
if (shp_int == '0') {
jAlertifyAlert('Its Look Like Shipping Stop In Receiver Country ' + shp_int, 'Shipping Error');
return false;
}
if ($.isNumeric(shp_price)) {
var orderPrice = parseFloat($('.pGrandTotal ').attr('data-total'));
var weight = parseFloat($('.totalWeightInput').val());
var unitWeight = Math.ceil(weight / shp_weight);
var shippingPrice = parseFloat(shp_price);
shippingPrice = eval(shippingPrice * unitWeight);
var total = eval(orderPrice + shippingPrice);
$('.pGrandTotal ').text(total).addClass('btn-danger');
var priceCode = $('#priceCodeShippingWidget').val();
$('.pShippingPriceTemp').text(shippingPrice + " " + priceCode);
$('.cartSubmit1').removeAttr('disabled');
}
} else {
jAlertifyAlert('Its Look Like Shipping Is Not Available In Receiver Country', 'Shipping Error');
}
$("#cartLoading").slideUp(500);
}
});
intshp = isInternationalShippingWidget();
if (intshp == false) {
$('.cartSubmit1').attr('disabled', 'true');
}
}
function isInternationalShippingWidget() {
chk = true;
receiverCountry = $("#shippingWidget").val();
storeCounntry = $("#storeCountryShippingWidget").val();
$('.interShipping').each(function(i, data) {
$(this).closest('tr').find('td').removeClass('btn-danger cartProductHighLight');
if (receiverCountry == storeCounntry) {
return true;
} else if ($(this).val() == '0') {
tr = $(this).closest('tr').find('td').addClass('btn-danger cartProductHighLight');
chk = false;
}
});
if (!chk) {
notification("Shipping Error", "Highlight Product Are not ship in receiver country.", "btn-danger");
return false;
}
return chk;
}
function removeFromSearch(param, value) {
makeAdvanceSearchForm(param, value);
//param is parameter name and value its value to remove from search
}
function makeAdvanceSearchForm(param, value) {
var isFind = false;
if (param == undefined || param == '' || param == null) {
param = '';
}
if (value == undefined || value == '' || value == null) {
value = '';
}
var p = "?";
//get search query Info
var search = getParam('s');
if (search == "" || search === undefined) {
search = '';
} else {
if (param != 's') {
search = p + "s=" + search;
p = "&";
}
}
//get category Info
var catT = getParam('cat');
var catId = '';
pcatId = $('.activeCategory').val();
if (pcatId != '' && catT == "") {
catT = pcatId;
}
if (catT == "" || catT === undefined) {
catId = '';
} else {
if (param != 'cat') {
catId = p + "cat=" + catT;
p = "&";
}
}
//get price info
var minPrice = $('#priceMin').val();
var minPriceData = $('#priceMin').attr('data-min');
var maxPrice = $('#priceMax').val();
var maxPriceData = $('#priceMax').attr('data-max');
var price = "";
if (minPrice != minPriceData || maxPrice != maxPriceData) {
if (param != 'price') {
price = p + "pMin=" + minPrice + "&pMax=" + maxPrice;
p = "&";
}
}
//get Color Data
var color = "";
$('.colorCheckBoxes input:checked').each(function() {
if (param == 'color' && value == $(this).val()) {} else {
color = $(this).val() + "," + color;
}
});
if (color != "") {
color = p + "color=" + color;
p = "&";
}
//get size
var size = "";
$('.sizeCheckBoxes input:checked').each(function() {
if (param == 'size' && value == $(this).val()) {} else {
size = $(this).val() + "," + size;
}
});
if (size != "") {
size = p + "size=" + size;
p = "&";
}
var link = search + catId + price + color + size;
location.replace("https://sharkspeed.se/search" + link);
}
//Scroll product load
moreProduct = true;
load = false;
$(document).scroll(function() {
if ($('.iHaveProducts').height() - $(window).height() < $(window).scrollTop() && moreProduct == true && load == false) {
load = true;
limitFrom = parseInt($('#queryLimit').val());
if (limitFrom == '' || isNaN(limitFrom)) {
return false;
}
limit = parseInt($('#queryLimit').attr('data-id'));
limitTo = eval(limitFrom + limit);
temp = '' + loading_progress() + '
';
view = $('#viewType').val();
$('.iHaveProducts').append(temp);
q_tempTable = $("#q_tempTable").val();
console.log('limitFrom : ' + limitFrom + ' | limitTO : ' + limitTo + ' | qTemp : ' + q_tempTable);
if ($("#productPage").val() == 'deal') {
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=more_product&productDeals";
} else {
url = "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=more_product";
}
$.ajax({
type: "POST",
url: url,
data: {
id: q_tempTable,
limitFrom: limitFrom,
limitTo: limitTo,
limit: limit,
view: view
}
}).done(function(data) {
load = false;
$(".loadingDivTemp").remove();
if (data == '0' || data == '' || parseInt(data) == 0) {
moreProduct = false;
} else {
$('#queryLimit').val(limitTo);
$('.iHaveProducts').append(data);
$(document.body).trigger("sticky_kit:recalc");
}
});
}
});
function dealProductAddToCart(ths, dealId, multiPro = 0) {
// check All select?
var allOk = true;
pArry = '';
var hasCustomQty = $('.addByQty_hidden_' + dealId).val();
var customQty = '';
if (hasCustomQty == '1') {
customQty = $('.addByQty_' + dealId).val();
var qtyMax = parseFloat($('.addByQty_' + dealId).attr("max"));
if (customQty > qtyMax) {
jAlertifyAlert("Product exced Stock qty, max value is : " + qtyMax + "
");
return false;
}
if (customQty >= '1' || customQty >= 1) {
//ok
} else {
jAlertifyAlert("Ange antal
");
$('.addByQty_' + pId).focus();
return false;
}
}
if (multiPro == 0) {
$('.dealsProducts').each(function(e, data) {
pId = $(this).val();
pName = $('.pName_' + pId).val();
hasColor = $('#hasColor_' + pId).val();
hasScale = $('#hasScale_' + pId).val();
size = $('.sizeSelect_' + pId + ":checked");
color = $('.colorSelect_' + pId + ':checked');
scaleId = size.attr('data-id');
if (hasScale == '0') {
scaleId = '0';
}
colorId = color.attr('data-id');
if (hasColor == '0') {
colorId = '0';
}
storeId = $('#store_' + pId).val();
if (scaleId == undefined || isNaN(scaleId) || colorId == undefined || isNaN(colorId)) {
allOk = false;
return false;
} else {
pArry += '{"pId":' + pId + ',"scaleId":' + scaleId + ',"colorId":' + colorId + ',"storeId":' + storeId + '},';
}
});
} else {
$('.dealsProductsMulti').each(function(e, data) {
pId__ = $(this).val();
pId = $(this).attr('data_id');
active = $('#active_' + pId).val();
console.log(pId__, " - ", pId, " - ", active);
if (active == 1 || pId__ > 10) {
console.log("if")
} else {
console.log("else")
allOk = false;
return false;
}
pName = $('.pName_' + pId).val();
hasColor = $('#hasColor_pro_' + pId).val();
hasScale = $(`#hasScale_pro_${pId}_${pId__}`).val();
size = $('.sizeSelect_' + pId__ + ":checked");
color = $('.colorSelect_' + pId__ + ':checked');
console.log(size)
scaleId = size.attr('data-id');
if (hasScale == '0') {
scaleId = '0';
}
colorId = color.attr('data-id');
if (hasColor == '0' || colorId == undefined) {
colorId = '0';
}
storeId = $('#store_pro_' + pId).val();
console.log('scaleId', scaleId)
if (scaleId == undefined || isNaN(scaleId)) {
allOk = false;
return false;
} else {
pArry += '{"pId":' + pId__ + ',"scaleId":' + scaleId + ',"colorId":' + colorId + ',"storeId":' + storeId + '},';
}
})
// allOk = false
}
console.log(pArry);
if (allOk == false) {
jAlertifyAlert("Välj Storlek eller/och Färg för alla produkter
");
return false;
} else {
$("#packInfo").val(pArry);
dealId = $("#packDealId").val();
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled != 1) {
$("#cartLoading").slideDown(500);
} else {
$("#cartLoading").slideDown(500);
$('.overlay').show();
$('#overlay_container').show();
$("#cart_side").animate({
"top": "50%"
}, "fast", function() {
/* stuff to do after animation is complete */
});
}
$.ajax({
type: "POST",
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=AddToCartDeal",
data: {
deal: pArry,
dealId: dealId,
customQty: customQty
}
}).done(function(data) {
$("#cartLoading").slideUp(500);
if (data == '1' || data == '') {
show_modal = (typeof(show_modal) == 'undefined' ? false : true);
if (cart_load_from_side_enabled == 1) {
cart_load_from_side();
if (show_modal) {
$("#cartLoading").slideUp(500);
};
} else {
$("#cartLoading").slideUp(500);
}
updateCartNoOnWeb();
cartSmallProduct();
} else {
jAlertifyAlert(data);
}
});
}
}
function buy_get_free() {
$(".buy_2_get_1_free").each(function() {
buy_qty = parseInt($(this).val());
cart_id = parseInt($(this).attr("data-id"));
p_qty = parseInt($(".cart_product_" + cart_id).find(".pQty").text());
if (p_qty >= buy_qty) {
free_qty = Math.floor(p_qty / buy_qty);
$(".cart_product_" + cart_id).find(".you_get_free_qty").text(free_qty);
$(".cart_product_" + cart_id).find(".buy_2_get_1_free_div").show(500);
} else {
$(".cart_product_" + cart_id).find(".buy_2_get_1_free_div").hide(500);
}
});
}
function get_payment_type() {
return $(".paymentOptionRadio:checked").val();
}
function add_payment_method_price() {
payment_type = get_payment_type();
price = parseFloat($(".payment_method_price_" + payment_type).val());
if (price > 0) {
total_price = parseFloat($(".pGrandTotal").attr("data-total"));
total_price = total_price + price;
$(".pGrandTotal").text(total_price);
//add in shipping price
shipping_price = parseFloat($('.pShippingPriceTemp').attr("data-real"));
shipping_price = shipping_price + price;
$('.pShippingPriceTemp').text(shipping_price);
} else {
total_price = parseFloat($(".pGrandTotal").attr("data-total"));
$(".pGrandTotal").text(total_price);
//add in shipping price
shipping_price = parseFloat($('.pShippingPriceTemp').attr("data-real"));
$('.pShippingPriceTemp').text(shipping_price);
}
}
function loadCustomFormInfo(customId) {
$('.loadCustomFormInfo').html(loading_progress());
url = "https://sharkspeed.se/src/model.php?page=loadCustomFormInfo&id=" + customId;
$('.loadCustomFormInfo').load(url);
}
function checkout_offers_script() {
$("#sample dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
$("#sample_select dd ul").fadeOut(600);
});
$("#sample dd ul li a").click(function() {
var text = $(this).html();
console.log($(this).prevAll('li'));
console.log('checkout_offers_script : ' + text);
// show the selected size
$(this).closest('dd').prev('dt').find('a > span').html(text);
$("#sample dd ul").fadeOut(600);
});
$("#sample_select dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
console.log('clicksize');
$("#sample dd ul").fadeOut(600);
});
$("#sample_select dd a").click(function() {
console.log('Clicked Size');
console.log($(this).html());
// save the selected size
var size_selected = $(this).find('div.color_name.size').html();
// hide the ul
$(this).closest('ul').hide();
// show the selected size
$('#sample_select > dt > a > span').html(size_selected);
});
$("#productSearchAutoComplete_select dd ul li a").click(function() {
var text = $(this).html();
$("#sample_select dt a span").html(text);
$("#sample_select dd ul").fadeOut(600);
});
}
function donot_forget_offers_script() {
$("#sample dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
$("#sample_select dd ul").fadeOut(600);
});
$("#sample dd ul li a").click(function() {
var text = $(this).html();
console.log($(this).prevAll('li'));
console.log('checkout_offers_script : ' + text);
// show the selected size
$(this).closest('dd').prev('dt').find('a > span').html(text);
$("#sample dd ul").fadeOut(600);
});
$("#sample_select dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
console.log('clicksize');
$("#sample dd ul").fadeOut(600);
});
$("#sample_select dd a").click(function() {
console.log('Clicked Size');
console.log($(this).html());
// save the selected size
var size_selected = $(this).find('div.color_name.size').html();
// hide the ul
$(this).closest('ul').hide();
// show the selected size
$('#sample_select > dt > a > span').html(size_selected);
});
$("#productSearchAutoComplete_select dd ul li a").click(function() {
var text = $(this).html();
$("#sample_select dt a span").html(text);
$("#sample_select dd ul").fadeOut(600);
});
var resp_imge = $('.pop_slide_main').length;
if (resp_imge == 0) {
$('.pop_side').hide();
} else if (resp_imge == 1) {
$('.pop_btn').hide();
} else {
console.log(resp_imge + "222222222sdsdasdasdsad4545");
var owl = $('.pop_slide').owlCarousel({
items: 1,
loop: true
});
owl.trigger('refresh.owl.carousel');
}
$('.button_side2').click(function() {
$('.pop_side').fadeOut();
});
}
//Color n Size Dropdown Script
$(document).ready(function() {
$("#sample dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
$("#sample_select dd ul").fadeOut(600);
});
$("#sample dd ul li a").click(function() {
var text = $(this).html();
let proId = $(text).attr('data-id');
selectProduct1(proId)
// show the selected size
$(this).closest('dd').prev('dt').find('a > span').html(text);
// $("#sample dt a span").html(text);
$("#sample dd ul").fadeOut(600);
});
});
$(document).ready(function() {
$("#sample_select dt a").click(function() {
$(this).parent().next().find('ul').fadeToggle(600);
console.log('clicksize');
$("#sample dd ul").fadeOut(600);
});
$("#sample_select dd a").click(function() {
console.log('Clicked Size');
console.log($(this).html());
// save the selected size
var size_selected = $(this).find('div.color_name.size').html();
// hide the ul
$(this).closest('ul').hide();
// show the selected size
$('#sample_select > dt > a > span').html(size_selected);
});
$("#productSearchAutoComplete_select dd ul li a").click(function() {
var text = $(this).html();
$("#sample_select dt a span").html(text);
$("#sample_select dd ul").fadeOut(600);
});
});
//Quantity Button Script
$(document).ready(function() {
// This button will increment the value
$('.qtyplus').click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal)) {
// Increment
$('input[name=' + fieldName + ']').val(currentVal + 1);
} else {
// Otherwise put a 0 there
$('input[name=' + fieldName + ']').val(0);
}
});
// This button will decrement the value till 0
$(".qtyminus").click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 1) {
// Decrement one
$('input[name=' + fieldName + ']').val(currentVal - 1);
} else {
// Otherwise put a 1 there
$('input[name=' + fieldName + ']').val(1);
}
});
});
function dontForgetProductSlider() {
console.log("dontForgetProductSlider")
$('#doNotForgetProductDiv').owlCarousel({
loop: true,
navigation: true,
items: 7,
responsiveClass: true,
responsive: {
0: {
items: 3,
nav: true
},
300: {
items: 3,
nav: false
},
400: {
items: 3,
nav: false
},
500: {
items: 3,
nav: false
},
600: {
items: 3,
nav: false
},
750: {
items: 3,
nav: true,
},
800: {
items: 3,
nav: true,
},
900: {
items: 3,
nav: true,
},
1000: {
items: 3,
nav: true,
},
1200: {
items: 3,
nav: true,
},
1280: {
items: 3,
nav: true,
}
}
})
}
function total_text_for_input() {
var total_text_for_input = "BESTÄLL FÖR - ";
return total_text_for_input;
}
function cart_load_from_side2(to_scroll) {
$.post('https://sharkspeed.se/ajax_call.php?page=cart_side_view', {
param1: 'value1'
}, function(data, textStatus, xhr) {
var parsed_data = JSON.parse(data);
console.log("parsed_data", parsed_data);
$('.cartItemNo').text(parsed_data.qty);
})
}
function cart_load_from_side(to_scroll) {
var to_scroll = typeof(to_scroll) === 'undefined' ? true : to_scroll;
$('.overlay').show();
$('#overlay_container').show();
$.post('https://sharkspeed.se/ajax_call.php?page=cart_side_view', {
param1: 'value1'
}, function(data, textStatus, xhr) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
console.log("parsed_data", parsed_data);
$('#doNotForgetProductDiv').html(parsed_data.doNotForgetProducts);
setTimeout(() => {
dontForgetProductSlider()
}, 2000)
$('#cart_items_container').html(parsed_data.products);
$('#coupon_text').html(parsed_data.coupon_text);
$('#coupon_remove_text').html(parsed_data.remove_coupon_text);
$('#three_for_two_text').html(parsed_data.three_for_2_cat_div);
$('#staple_product_text').html(parsed_data.staple_pro_cat_div);
$('#giftcard_text').html(parsed_data.msg);
$('#giftcard_remove_text').html(parsed_data.removeGiftCard);
$('#price_simple').val(parsed_data.price_simple);
}).done(function() {
$("#cart_side").animate({
"top": "50%"
}, "fast");
$("#cartLoading").slideUp(500);
console.log('INSIDE DONE');
});
}
$('#goToCartOptionId').on('click', '#go_to_checkout, #continue_shopping', function(event) {
event.preventDefault();
var cart_load_from_side_enabled = 1;
var old_val = parseInt($('#order_submit').val());
if (cart_load_from_side_enabled == 1) {
if (this.id == 'go_to_checkout') {
$("#cartLoading").slideDown(500);
if (old_val > '1') {
$('#checkoutOfferModal').modal('hide');
cart_load_from_side_submit();
} else {
console.info('old_val is: ' + old_val);
cart_load_from_side();
};
} else {
$('#checkoutOfferModal').modal('hide');
}
$('#goToCartOptionId').modal('hide');
console.log('Clicked on ' + this.id);
console.log('Cart load from side is enabled!');
}
});
$('body').on('click', '#alertify-ok', function(event) {
event.preventDefault();
$("#cartLoading").slideUp(500);
});
$('#checkoutOfferModal').on('click', '#checkout_offer_dismiss_btn', function(event) {
event.preventDefault();
$("#cartLoading").slideDown(500);
cart_load_from_side_submit();
});
$('body').on('click', '.overlay', function(event) {
event.preventDefault();
/* Act on the event */
console.log('clicked on body');
var target = $(this);
$("#cart_side").animate({
"top": "-200%"
}, "fast", function() {
console.log('flow_hide 1')
$('body').removeClass('flow_hide');
console.log('in cart side function');
target.hide();
$('#overlay_container').hide();
});
});
function scroll_to_top(to_scroll) {
condition = ($(window).width() <= 758);
if (typeof(to_scroll) !== 'undefined') {
if (to_scroll == false) {
return false;
};
}
condition = true; // hardcoding true, scroll to top always.
if (condition) {
$('body').animate({
scrollTop: 0
}, '1000');
$("html, body").animate({
scrollTop: 0
}, "slow");
console.log('Scrolled to top');
}
}
$('#scroll_responsive_section').on('click', '#responsive_cart_menu', function(event) {
event.preventDefault();
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled == 1) {
$("#cartLoading").slideDown(500);
console.log('flow_hide 2')
$('body').addClass('flow_hide');
cart_load_from_side();
}
});
$('#RootNode').click(function() {
cart_load_from_side();
});
$('#sw').click(function() {
$(".search_mobile").fadeToggle();
});
$('#RootNode1').click(function() {
cart_load_from_side();
});
$('#cart_area').on('click', '#cart', function(event) {
event.preventDefault();
var cart_load_from_side_enabled = 1;
if (cart_load_from_side_enabled == 1) {
$("#cartLoading").slideDown(500);
cart_load_from_side();
}
});
function cart_load_from_side_coupon_set(isCheckout = false) {
var coupon_val = $('#coupon_input').val();
if (coupon_val == '') {
return false;
};
$.post('https://sharkspeed.se/ajax_call.php?page=set_unset_coupon', {
coupon: coupon_val
}, function(data, textStatus, xhr) {
var parsed_data = JSON.parse(data);
if (cart_load_from_side_coupon_set) {
jAlertifyAlert(parsed_data.coupon_text);
if (parsed_data.coupon_applied == false || parsed_data.coupon_applied == undefined) {} else {
cart_load_from_side_submit()
}
} else {
$('#cart_items_container').html(parsed_data.products);
$('#coupon_text').html(parsed_data.coupon_text);
$('#coupon_remove_text').html(parsed_data.remove_coupon_text);
$('#cart_side_grandtotal').val(total_text_for_input() + parsed_data.price_simple + " " + parsed_data.symbol);
}
});
}
$('#side_coupon_container').on('click', '#side_coupon_submit', function(event) {
event.preventDefault();
/* Act on the event */
console.log('Clicked on coupon submit button');
cart_load_from_side_coupon_set();
});
function cart_load_from_side_gift_set(isCheckout = false) {
var giftcard_val = $('#giftcard_input').val();
if (giftcard_val == '') {
return false;
};
$.post('https://sharkspeed.se/ajax_call.php?page=set_unset_giftcard', {
giftcard: giftcard_val
}, function(data, textStatus, xhr) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
if (isCheckout) {
jAlertifyAlert(parsed_data.msg);
console.log(parsed_data.error)
if (parsed_data.error === true || parsed_data.error === undefined) {
} else {
cart_load_from_side_submit();
}
} else {
$('#cart_items_container').html(parsed_data.products);
$('#giftcard_text').html(parsed_data.msg);
$('#giftcard_remove_text').html(parsed_data.removeGiftCard);
$('#cart_side_grandtotal').val(total_text_for_input() + parsed_data.price_simple + " " + parsed_data.symbol);
}
console.log(parsed_data.error);
if (parsed_data.error) {
} else {
$("#gft_id").hide();
}
});
}
function cart_load_from_side_gift_remove(isCheckout = false) {
$.post('https://sharkspeed.se/ajax_call.php?page=set_unset_giftcard', {
remove_giftcard: 1
}, function(data, textStatus, xhr) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
if (isCheckout) {
cart_load_from_side_submit()
} else {
$('#cart_items_container').html(parsed_data.products);
$('#giftcard_text').html(parsed_data.msg);
$('#giftcard_remove_text').html('');
$('#giftcard_input').val('');
}
$('#cart_side_grandtotal').val(total_text_for_input() + parsed_data.price);
});
}
function cart_load_from_side_coupon_remove(isCheckout = false) {
$.post('https://sharkspeed.se/ajax_call.php?page=set_unset_coupon', {
remove_coupon: 1
}, function(data, textStatus, xhr) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
if (isCheckout) {
cart_load_from_side_submit()
} else {
$('#cart_items_container').html(parsed_data.products);
$('#coupon_text').html(parsed_data.coupon_text);
$('#coupon_remove_text').html('');
$('#coupon_input').val('');
$('#cart_side_grandtotal').val(total_text_for_input() + parsed_data.price_simple + " " + parsed_data.symbol);
}
});
}
function something_extra_products(invoiceId) {
$.get('https://sharkspeed.se/ajax_call.php?page=something_extra_products', {
invoiceId: invoiceId,
}, function(data) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
$('#something_extra_products').html(parsed_data.somethingExtraProduct);
$('.owl_carousel_checkout').owlCarousel({
items: 2,
loop: true,
margin: 15,
dots: true,
nav: true,
navText: ["chevron_left
", "chevron_right
"],
responsive: {
300: {
items: 1,
},
500: {
items: 1
},
750: {
items: 2
},
1180: {
items: 2
}
}
})
});
}
function cart_side_load_order_file(invoiceId) {
$("#cartLoading").slideDown(500);
$.get('https://sharkspeed.se/ajax_call.php?page=cart_side_load_order_file', {
invoiceId: invoiceId,
}, function(data) {
/*optional stuff to do after success */
something_extra_products(invoiceId);
var parsed_data = JSON.parse(data);
var giftCardId = parsed_data.giftCardId;
var giftCardPrice = parsed_data.giftPrice;
var coupon_applied = parsed_data.coupon_applied;
console.log(parsed_data.new_cart_side_order_products_html);
console.log($('#ordered_products_area'));
$('#overlay_order_container').html(parsed_data.order_popup_html);
$('#overlay_order_container').append(parsed_data.cartCustomSizeModals);
$('#ordered_products_area').html(parsed_data.new_cart_side_order_products_html);
$('#ordered_prices').html(parsed_data.order_price_html);
$('#shippingPrice').append(`${parsed_data.shipPrice} ${parsed_data.symbol}`);
$("html, body").animate({
scrollTop: "0"
}, 100);
$('body').addClass('flow_hide');
$("#cartLoading").slideUp(500);
if (giftCardId !== "") {
$(".gift_card").hide();
$(".alreadyGiftCardApplied").show();
$('#alreadyGiftCardAppliedText').append(`${giftCardId} (${giftCardPrice})`);
}
if (coupon_applied) {
$(".dis_card").hide();
$(".alreadyDisCardApplied").show();
}
});
}
function cart_load_from_side_submit() {
console.log('cart_load_from_side_submit clicked')
var serialized = $('#cart_side_form').serialize();
var old_val = parseInt($('#order_submit').val());
$.get('https://sharkspeed.se/ajax_call.php?page=cart_side_submit&' + serialized, function(data) {
/*optional stuff to do after success */
var parsed_data = JSON.parse(data);
if (old_val == '1' && parsed_data.checkout_offer != '') {
console.log(1)
$('#checkout_offer_container').html(parsed_data.checkout_offer);
$('#checkoutOfferModal').modal('show');
checkout_offers_script();
} else {
console.log(2)
cart_side_load_order_file(parsed_data.invoiceId);
};
$("#cart_side").animate({
"top": "-500%"
}, "fast");
$('.cartItemNo').text(parsed_data.qty);
$('.cartPriceAjax').text(parsed_data.price);
});
$('#order_submit').val(old_val + 1);
}
$('#side_giftcard_container').on('click', '#side_giftcard_submit', function(event) {
event.preventDefault();
console.log('Clicked on giftcard submit button');
cart_load_from_side_gift_set();
});
$('#giftcard_remove_text').on('click', '#giftcard_remove', function(event) {
event.preventDefault();
console.log('Clicked on giftcard remove button');
cart_load_from_side_gift_remove();
$("#gft_id").show();
});
$('#coupon_remove_text').on('click', '#coupon_remove', function(event) {
event.preventDefault();
console.log('Clicked on coupon remove button');
cart_load_from_side_coupon_remove();
});
$('#cart_side_form').on('click', '#cart_side_grandtotal', function(event) {
event.preventDefault();
console.log('Clicked on cart submit button');
cart_load_from_side_submit();
});
function selectProduct1(proId) {
console.log(proId)
let tabId = $(`.pro_${proId}__tab`).val();
let image = $(`.pro_${proId}__${tabId}__image`).val();
if (tabId !== undefined && image !== undefined) {
// set image
let id = `dealTab_${tabId}`
let imgTag = ``
$(`#${id}`).html(imgTag)
let dealsProducts_pro = `dealsProducts_pro_${tabId}`
let currency_pro_ = `currency_pro_${tabId}`
let checkout_pro = `checkout_pro_${tabId}`
let active_ = `active_${tabId}`
let pName_ = `pName_${tabId}`
$(`#${dealsProducts_pro}`).val(proId);
$(`#${checkout_pro}`).val(proId);
$(`#${active_}`).val(1);
}
}
function selectProduct(tabId, proId, Img, pName) {
let allOk = true;
let hasColor_pro = `hasColor_pro_${tabId}`
hasColor_pro = $(`#${hasColor_pro}`).val();
let hasScale_pro = `hasScale_pro_${tabId}_${proId}`
hasScale_pro = $(`#${hasScale_pro}`).val();
let color = "";
let size = "";
if (hasScale_pro == "1") {
size = $(`.sizeSelect_${proId}:checked`).val();
}
if (hasColor_pro == "1") {
color = $('.colorSelect_' + proId + ':checked').val();
}
if (hasScale_pro == "1" && (size == "" || size == undefined)) {
allOk = false;
}
if (allOk == false) {
jAlertifyAlert("Please select product size/color.
");
} else {
let id = `dealTab_${tabId}`
let imgTag = ``
$(`#${id}`).html(imgTag)
let dealsProducts_pro = `dealsProducts_pro_${tabId}`
let currency_pro_ = `currency_pro_${tabId}`
let checkout_pro = `checkout_pro_${tabId}`
let active_ = `active_${tabId}`
let pName_ = `pName_${tabId}`
$(`#${dealsProducts_pro}`).val(proId);
$(`#${checkout_pro}`).val(proId);
$(`#${pName_}`).val(pName);
$(`#${active_}`).val(1);
}
}
$('.close_pupup23').click(function() {
$(".newcart_popup").removeClass('newcart_popup_');
cart_load_from_side();
});
$("#expressMode").change(function() {
var currentUrl = window.location.href;
var currentTitle = document.title;
var isChecked = this.checked;
$(this).closest('.switch').toggleClass('on', isChecked);
var status = isChecked ? 'checked' : 'unchecked';
$.ajax({
url: "https://sharkspeed.se/_models/functions/products_ajax_functions.php?page=setExpressMode",
type: "POST",
data: {
value: status
},
success: function(res) {
if (res == "checked") {
loadPage(currentUrl, currentTitle);
} else if (res == "unchecked") {
loadPage(currentUrl, currentTitle);
}
},
error: function(xhr, status, errorThrown) {
console.error(xhr.responseText);
}
});
});