$(document).ready(function () { /* $('#menu').slicknav();*/ $(".accordion").accordion({ heightStyle: "content" }); //auto complete for product $(".txt_search").autocomplete({ source: function (request, response) { $.ajax({ url: "https://paklibya.com.pk/_models/functions/products_ajax_functions.php?page=getSearchJson&limit=3&val=" + $('.txt_search').val(), success: function (data) { response(eval(data)); } }); }, minLength: 3, select: function (event, ui) { $('.txt_search').val(ui.item.label); $('#searchForm').submit(); }, open: function () { $(this).removeClass("ui-corner-all").addClass("ui-corner-top"); $('.ui-menu').width(300); $(".ui-autocomplete").position({ my: "left bottom", at: "left top", of: $(".txt_search"), collision: "flip flip" }); }, position: { my : "right top", at: "right bottom"}, close: function () { $(this).removeClass("ui-corner-top").addClass("ui-corner-all"); } }).data("ui-autocomplete")._renderItem = function (ul, item) { return $("
  • ") .data("item.autocomplete", item) .css({ "margin": "1px 0", "height": "85px", "padding": "5px" }) .append("
    " + "
    " + "" + "
    " + "
    " + item.name + "
    " + item.oldPrice + "   " + item.newPrice + "
    " + "
    ") .appendTo(ul); }; /* $('.txt_search').keyup(function(){ srch = $('.txt_search').val(); if(srch.length>=3){ productSearch(srch); } });*/ }); function productSearch() { //not in use,, built for get product for search srch = $('.txt_search').val(); $.ajax({ type: 'GET', url: 'https://paklibya.com.pk/_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://paklibya.com.pk/_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); }; } //Create Link function link(id) { //document.location.href="?product="+url; 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() { //document.location.href="?product="+url; 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'); if (isNaN(cat)) { // cat = ""; } url = '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); }); //////////////////////// /* $('.paymentOptionRadio').change(function () { paymentOption = $('.paymentOptionRadio:checked').val(); //0 cash on delivery //1 paypal //2 klarna //5 pason //6 GiftCard //7 2 checkout if (paymentOption == '0' || paymentOption == '1' || paymentOption == '5' ) { $("#cartLoading").slideDown(500); inv = $('#invoiceId').val(); $.ajax({ type: "POST", url: "cartContinue.php?inv=" + inv + "&paymentOption=" + paymentOption }).done(function (data) { $("#cartLoading").slideUp(500); $("#cartContinue").html(data); add_payment_method_price(); }); return true; } else if (paymentOption == '2') { inv = $('#invoiceId').val(); url = 'klarna.php?ajax=1&inv=' + inv; $("#cartLoading").slideDown(500); $.ajax({ type: "POST", url: url }).done(function (data) { $("#cartLoading").slideUp(500); $("#cartContinue").html(data); add_payment_method_price(); }); return true; } else { $("#cartContinue").html(""); } }); */ $('#paymentOptionNext').on('click', function(event) { event.preventDefault(); /* Act on the event */ // $('.paymentOptionRadio').change(function () { if ( $('.paymentOptionRadio').is(":checked") ) { paymentOption = $('.paymentOptionRadio:checked').val(); //0 cash on delivery //1 paypal //2 klarna //5 pason //6 GiftCard //7 2 checkout if (paymentOption == '0' || paymentOption == '1' || paymentOption == '5' ) { $("#cartLoading").slideDown(500); inv = $('#invoiceId').val(); $.ajax({ type: "POST", url: "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 = '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 { $("#cartContinue").html(""); add_payment_method_price(); } }; // }); }); }); function quickView(ths,productId){ //echo $productClass->productQuickViewModel(); //call productQuickViewModel() in end of footer file.. //link(productId); //link updating is stop due to some parametrs are remove var url = "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) { // console.log(pId); // return false; // 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).hide(); $('#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 setOldDefaultPrice (pId) { currency = $('#currency_' + pId); defaultPrice = currency.attr('data-defaultprice'); //console.log(defaultPrice); $('.productOldPrice_'+pId).text(defaultPrice); } function stockPrint(pId, data) { 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(""+data+" Items In Stock - stocklocation: "+location_+""); var hasCustomQty = $('.addByQty_hidden_' + pId).val(); var customQty = ''; if(hasCustomQty=='1'){ if(data>0) { $('.addByQty_' + pId).attr("max", data); //$('.addByQty_' + pId).val(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) { // console.log("price:"+price); price1 = productRealPrice(pId); // console.log("price1:"+price1); total = eval(price1 + parseFloat(price)); //$('.productPrice_' + pId).text(price1); currency = $('#currency_' + pId); discountFormat = currency.attr('data-discountformat'); discountP = parseFloat(currency.attr('data-discountp')); discount = discountCalculation(total, discountP, discountFormat); //DiscountFormat = "price" //DiscountVal = "50" //total = eval(); // console.log("total:"+total); // console.log("discount:"+discount); $('.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 ) { //use for scale price update setTimeout( function () { updatePrice(pId) }, 400 ); } function updatePrice(pId) { 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; } realPrice = parseFloat(currency.attr('data-defaultprice')); discountFormat = currency.attr('data-discountformat'); discountP = parseFloat(currency.attr('data-discountp')); total = eval(realPrice + colorPrice + sizePrice); discount = discountCalculation(total, discountP, discountFormat); //DiscountFormat = "price" //DiscountVal = "50" //total = eval(); $('.productOldPrice_' + pId).text(total); $('.productPrice_' + pId).text(discount); productStockCheck(pId, sizeId, colorId); } } } 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 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); 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://paklibya.com.pk/_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) { // console.log('1'); if(scaleId == '-1'){ $('.AddToCart_' + pId).hide(100); $('.AddToCart_' + pId).removeAttr("disabled", "disabled"); $('.AddToCart_' + pId).attr("data-scaleSelect", "1"); stockPrint(pId, ''); customFormAddProductFields(pId); return true; } // console.log('2'); $('.AddToCart_' + pId).show(500); // console.log('3'); inventoryLimit = $('#deatilStockCheck_' + pId).val(); // console.log('4'); if(inventoryLimit == '0'){ $('.AddToCart_' + pId).removeAttr("disabled", "disabled"); $('.AddToCart_' + pId).attr("data-scaleSelect", "1"); stockPrint(pId, ""); return true; } // console.log('5'); 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) { /*$('#stock_'+pId).html(data+" Exemplar i lager");*/ // console.log(data); stockPrint(pId, data); if (data == 0) { $('.AddToCart_' + pId).attr("disabled", "disabled"); $('.AddToCart_' + pId).attr("data-scaleSelect", "0"); } else { $('.AddToCart_' + pId).removeAttr("disabled", "disabled"); $('.AddToCart_' + pId).attr("data-scaleSelect", "1"); } }); } var checkOutOfferAddtoCart = false; // use this var for check is client add to cart checkout offer or not function addToCart(ths, pId, refresh) { hasColor = $('#hasColor_' + pId).val(); hasScale = $('#hasScale_' + pId).val(); scaleSelect = $(ths).attr('data-scaleSelect'); if ( ( scaleSelect == 0 || scaleSelect == '0' || isNaN(scaleSelect) ) && hasScale == '1' && hasColor == '1' ) { //jAlertifyAlert("Your Selected Item Not in stock. Or select Product Size/Color"); //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("Please Enter Correct Number.

    "); $('.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(); //Out of stock qty trigger qty = $('#hidden_stock_' + pId).val(); if(qty <=0){ out_of_stock_trigger(pId,colorId,scaleId,storeId); return false; } productPriceUpdate(); if($("#checkout_"+pId).val()==pId){ checkOutOfferAddtoCart = true; url = "https://paklibya.com.pk/_models/functions/products_ajax_functions.php?page=AddToCart&checkout"; }else{ url = "https://paklibya.com.pk/_models/functions/products_ajax_functions.php?page=AddToCart"; } $("#cartLoading").slideDown(500); $.ajax({ type: "POST", url: url, data: {pId: pId, storeID: storeId, scaleId: scaleId, colorId: colorId , customQty:customQty} }).done(function (data){ $("#cartLoading").slideUp(500); if(data == '1' || data == ''){ updateCartNoOnWeb(); cartSmallProduct(); afterAddToCart_show_goToCart_option(); }else{ jAlertifyAlert(data); } }); if (refresh === true) { window.location = ''; }; } 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{ //alert("checkout"); return true; } } function cartSmallProduct() { var val = $('.cartSmallProduct').attr('data-value'); var val2 = $('.cartPriceAjax').attr('data-value'); var urlT = 'https://paklibya.com.pk/_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://paklibya.com.pk/_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://paklibya.com.pk/_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").text()); no = eval(no - 1); $(".cartItemNo").text(no); } function updateCartNoOnWebRemove(qty) { no = parseFloat($(".cartItemNo").text()); no = eval(no - qty); $(".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://paklibya.com.pk/_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_page_reload(); } 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://paklibya.com.pk/_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://paklibya.com.pk/_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, refresh) { qty = parseFloat($('#tr_' + cartId).find('.pQty').text()); $('.pGrandTotal,.pTotalWeight').html('Loading...'); $("#cartLoading").slideDown(500); $.ajax({ type: "POST", url: "https://paklibya.com.pk/_models/functions/products_ajax_functions.php?page=cartProductRemove", data: {cartId: cartId} }).done(function (data) { $("#cartLoading").slideUp(500); if (data == '1' || data == '') { updateCartNoOnWebRemove(qty); remove_div($('#tr_' + cartId), 0); $(".tr_"+cartId).hide(500); cartSmallProduct(); setTimeout(function () { totalPrice(); totalWeight(); }, 1200); if (typeof refresh === 'undefined') { cart_page_reload(); } } 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); /* $("#cartLoading").slideDown(500); $.ajax({ type: "POST", url : "cartContinue.php" }).done(function(data) { $("#cartLoading").slideUp(500); $("#cartContinue ").html(data); });*/ } 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 = "&"; } /* console.log(search); console.log(catId); console.log(price); console.log(color); console.log(size);*/ var link = search+catId+price+color+size; //console.log(link); location.replace("https://paklibya.com.pk/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(); if($("#productPage").val()=='deal'){ url = "https://paklibya.com.pk/_models/functions/products_ajax_functions.php?page=more_product&productDeals"; }else { url = "https://paklibya.com.pk/_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){ // 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("Please Enter Correct Number.

    "); $('.addByQty_' + pId).focus(); return false; } } $('.dealsProducts').each(function(e,data){ pId = $(this).val(); pName = $('.pName_'+pId).text(); 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(); /* console.log(pId); console.log(pName); console.log(scaleId); console.log(colorId); */ if(scaleId == undefined || isNaN(scaleId) || colorId == undefined || isNaN(colorId) ){ allOk = false; return false; }else{ pArry += '{"pId":'+pId+',"scaleId":'+scaleId+',"colorId":'+colorId+',"storeId":'+storeId+'},'; } }); if(allOk == false){ jAlertifyAlert("Please select product's size/color of all package products"); return false; }else { // pArry = "["+pArry+"]"; $("#packInfo").val(pArry); dealId = $("#packDealId").val(); $("#cartLoading").slideDown(500); $.ajax({ type: "POST", url: "https://paklibya.com.pk/_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 == '') { updateCartNoOnWeb(); cartSmallProduct(); afterAddToCart_show_goToCart_option(); }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()); console.log(buy_qty); console.log(p_qty); 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://paklibya.com.pk/src/model.php?page=loadCustomFormInfo&id="+customId; $('.loadCustomFormInfo').load(url); }