').insertAfter('.quantity2 input'); jQuery('.quantity2').each(function() { var spinner = jQuery(this), input = spinner.find('input[type="number"]'), btnUp = spinner.find('.quantity2-up'), btnDown = spinner.find('.quantity2-down'), min = input.attr('min'), max = input.attr('max'); btnUp.click(function() { var oldValue = parseFloat(input.val()); var qtyIncrement = $("#qtyIncrement").val(); if (oldValue >= max) { var newVal = oldValue; } else { var stockProduct = $("#stockProduct").val(); var newVal = oldValue + parseInt(qtyIncrement); } spinner.find("input").val(newVal); spinner.find("input").trigger("change"); }); btnDown.click(function() { var oldValue = parseFloat(input.val()); var qtyIncrement = $("#qtyIncrement").val(); if (oldValue <= min) { var newVal = oldValue; } else { var newVal = oldValue - parseInt(qtyIncrement); } spinner.find("input").val(newVal); spinner.find("input").trigger("change"); }); }); var ulCart = jQuery("#ulCart"); /* PDP LIGHTBOX */ function openModal() { document.getElementById('myModal').style.display = "block"; } function closeModal() { document.getElementById('myModal').style.display = "none"; } var slideIndex = 1; showSlides(slideIndex); function plusSlides(n) { showSlides(slideIndex += n); } function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("pdp-slide"); // var captionText = document.getElementById("caption"); if (n > slides.length) { slideIndex = 1; } if (n < 1) { slideIndex = slides.length } for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex - 1].style.display = "block"; dots[slideIndex - 1].className += " active"; // captionText.innerHTML = dots[slideIndex-1].alt; } /* END PDP LIGHTBOX */ function getViewCart(){ jQuery.ajax({ type : 'GET', url : ctx + "/checkout/cart/ajax", datatype : 'json', cache: 'false', complete: function(){ jQuery("#ulCart").removeClass("reload"); }, success: function(data){ jQuery("#btnAddtocart").removeClass("disabled"); cartInfo = []; var indexNumber = 0; var subtotalawal = 0; var subtotal = 0; var freeongkir = "50000"; var persentase = 0; var ii = 0; var grandTotalProduct = 0; var deliveryLable = data.deliveryLabel; jQuery("#ulCart").empty(); if(data.listCart.productCart.length > 0){ subtotalawal = data.listCart.tbtcSubtotalAwal; subtotal = data.listCart.tbtcSubtotal; persentase = Math.floor((parseInt(subtotal) / parseInt(freeongkir)) * parseInt(100)); jQuery.each(data.listCart.productCart, function(i, v){ //console.log(data.listCart.productCart); var cartItem = new Object(); var tbmpSku = v.tbmpSku; var brands = v.brands; var categories = ((v.categories).replace(/[\[\]]/gi, "")).replace(/[|]/gi, "/"); var tbtcdQty = v.tbtcdQty; var tbmpLowestPrice = v.tbmpLowestPrice; var tbmpName = v.tbmpName; cartItem.name = tbmpName; cartItem.id = tbmpSku; cartItem.price = tbmpLowestPrice.toString(); cartItem.brand = brands; cartItem.category = categories; cartItem.quantity = Number(tbtcdQty); cartInfo.push(cartItem); var strtbmpName = tbmpName.length; var showLowPrice = ""; var maxQty = (v.tbmpiMaxSaleQty > 0) ? v.tbmpiMaxSaleQty : 999; if(v.tbmpPrice == v.tbmpLowestPrice) showLowPrice = "display:none"; if(strtbmpName > 40){ tbmpName = tbmpName.substr(0, 40) + "..."; } if(v.smallImage == ""){ var imgDefault = ctx + "/assets/desktop/img/alfacart_default.png"; }else{ var imgDefault = v.smallImage; } if(v.isGroceries == 0){ grandTotalProduct += parseInt(v.tbtcdSubtotal); } ulCart.append('