var products = []; products[1357] = ["Malware Shield", 99.95, "Luna Links", "Luna Links's Malware Shield solution protects you from malware in a couple of different ways. It prevents you from accidentally visiting malicious websites by restricting your access and showing you a warning message instead. Malware Shield also scans every file you download. If it detects malware in the file, it deletes it immediately, before the contents can do any damage to your device.", "", "Delicious & easy-to-chew gummies for sleep support."]; products[1358] = ["Rapid Clean Up ", 98.95, "Luna Links", "The Rapid Clean Up solution works by targeting all of the inefficiencies and clutter that build up on your computer over time. It performs a number of maintenance tasks that may take time or be hard to do individually, including: Emptying caches for various programs. Limiting processes from using RAM in the background.", "", ""]; products[1362] = ["Root Secure Plus", 119.95, "Luna Links", "Created for advanced use, the Root Secure Plus software enables root directory access to help you unlock the full potential of the PC. Once you have secured root access, you can enjoy super fast processing speed, power & performance.", "", ""]; products[1363] = ["Hard Disk Shield", 89.95, "Luna Links", "Hard Disk Shield is a hard disk monitoring software with highest possible support of HDD/SSD/SSHD (hybrid) drives. Its goal is to find, test, diagnose and repair hard disk drive problems, report and display SSD and HDD health, performance degradations and failures.", "", ""]; products[1359] = ["Password Protector", 79.95, "Luna Links", "Password Protector is a time saving solution that stores all passwords in one place. No more time wasted remembering where you wrote down your passwords. With Password Protector you'll never lose a password again! Password Protector works autonomously without any external data transfers to eliminate privacy and data leak risks.", "", ""]; products[1360] = ["Privacy Protector", 74.95, "Luna Links", "Privacy Protector will wipe out your online digital footprint, including your browsing history and tracking records. Privacy Protector will also provide you with an advanced file encryption mechanism to protect your personal and sensitive files.", "", ""]; products[1361] = ["Ultimate Clean Up Bundle ", 349, "Luna Links", "Bundled Products Included:", "", ""]; products[1364] = ["Ultimate Performance Bundle", 499, "Luna Links", "Bundled Products Included:", "", ""]; products[1365] = ["Platinum Protection Bundle", 549, "Luna Links", "Bundled Products Included:", "", ""]; products[1411] = ["System Upgrade Bundle", 699, "Luna Links", "Bundled Products Included:", "", ""]; products[2878] = ["Health Watch", 76.85, "Luna Links", "This slim, easy-to-use health watch with GPS and heart rate tracking built-in. Monitors your heart rate during exercise and resting heart rate for a holistic picture of your heart health. The health watch tracks your sleep pattern automatically, measuring deep sleep, light sleep, and wake-sleep. Accurately record all-day activities like steps, distance, calories burned, miles walked, active minutes, sleep status and more. Stay motivated all day! Enjoy up to 10 days of battery life for daily progress without constant charging.", "", ""]; products[2882] = ["2 in 1 phone screen cleaner spray", 21.5, "Luna Links", "Fingerprint-proof Screen Cleaner is a protective shell with a flat surface and a built-in bottle. The screen cleaner is designed with lipstick shape, so you can take it with you anywhere and use it anytime. The phone screen spray has the function of cleaning, disinfecting, antistatic, degreasing. Remove the oil and fingerprint. Easy to use, Spray the cleaning tip onto the screen from a distance of 1 to 2 inches and gently wipe the fiber cloth from the bottle to remove the stain.", "", ""]; products[2884] = ["Colorful Wireless Speaker", 37.9, "Luna Links", "This bluetooth speaker equips with a 15W full range driver, and advanced digital signal processor, which pumps out crisp treble, accurate mids and amazing deep bass, deliver 360° powerful stereo sound without distortion even at max volume. Different light mode is especially suitable for night events, mixed color flashes, react and phase to the beat of your music, create a pulsing light show for any song, and keep the party going with streaming music in wonderful lights. Advanced Bluetooth 5.0 effortlessly connects to all of your Bluetooth-enabled devices such as Smart phones, laptos, TV etc. ", "", ""]; console.log(products); var orderedItems = []; var orderedTotQty = 0; var maxQty = 10; var shipRates = false; var handling = 0; var carturl = "cart.php"; //Funtion adds Items to Cart var addItem = function(itemId, Qty) { orderedTotQty = $.cookie('orderedTotQty'); if (!orderedTotQty) { orderedTotQty = 0; } Qty = parseInt(Qty); if(Qty > maxQty) { alert("Maximum " + maxQty + " of this product can be selected in a single order"); return false; } var order = $.cookie('order'); if (!typeof order === 'string' && order.length === 0) { order = itemId + "-" + Qty; orderedItems[itemId] = Qty; } else { var itemExists = false; var items = order.split("|"); order = ""; for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (order != "") { order += "|"; } if (prodId == itemId) { alert("Product already exist in cart"); return false; if((quantity + Qty) > maxQty) { alert("Maximum " + maxQty + " of this product can be selected in a single order"); return false; } quantity += Qty; order += prodId + "-" + quantity; itemExists = true; } else { order += prodId + "-" + quantity; } orderedItems[prodId] = quantity; } if (!itemExists) { if (order != "") { order += "|"; } order += itemId + "-" + Qty; orderedItems[itemId] = Qty; } } orderedTotQty = parseInt(orderedTotQty); orderedTotQty += Qty; $('.cartqty').html(orderedTotQty); $.cookie('order', order); $.cookie('orderedTotQty', orderedTotQty); var url = window.location.pathname; var filename = url.substring(url.lastIndexOf('/') + 1); if (filename == carturl) { showCart(false, 'add', itemId); } else { //$(location).attr('href', carturl); } }; //Funtion decrements Items to Cart var removeItem = function(itemId, Qty) { Qty = parseInt(Qty); var order = $.cookie('order'); if (!order) { orderedItems[itemId] = 0; refreshRow(itemId); } else { var items = order.split("|"); order = ""; for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (prodId == itemId) { quantity -= Qty; if (quantity > 0) { if (order != "") { order += "|"; } order += prodId + "-" + quantity; } itemExists = true; orderedItems[prodId] = quantity; refreshRow(itemId); } else { if (order != "") { order += "|"; } order += prodId + "-" + quantity; orderedItems[prodId] = quantity; } } } orderedTotQty -= Qty; $('.cartqty').html(orderedTotQty); $.cookie('order', order); $.cookie('orderedTotQty', orderedTotQty); var url = window.location.pathname; var filename = url.substring(url.lastIndexOf('/') + 1); if (filename == carturl) { showCart(false, 'remove', itemId); } else { //$(location).attr('href', carturl); } }; //Funtion sets Item quantity on the Cart var setItemQty = function(itemId, Qty) { Qty = parseInt(Qty); if(Qty > maxQty || Qty < 0) { return false; } var order = $.cookie('order'); orderedTotQty = 0; if (!order) { orderedItems[itemId] = 0; } else { var items = order.split("|"); order = ""; for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (prodId == itemId) { quantity = Qty; if (order != "") { order += "|"; } order += prodId + "-" + quantity; itemExists = true; } else { if (order != "") { order += "|"; } order += prodId + "-" + quantity; } orderedItems[prodId] = quantity; orderedTotQty += quantity; } } $('.cartqty').html(orderedTotQty); $.cookie('order', order); $.cookie('orderedTotQty', orderedTotQty); var url = window.location.pathname; var filename = url.substring(url.lastIndexOf('/') + 1); if (filename == carturl) { showCart(false, 'set', itemId); } else { //$(location).attr('href', carturl); } }; var removeRowItem = function(itemId) { var order = $.cookie('order'); if (!order) { orderedTotQty = 0; } else { var items = order.split("|"); order = ""; orderedTotQty = 0; orderedItems = null; orderedItems = new Array(); for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (prodId == itemId) { } else { if (order != "") { order += "|"; } order += prodId + "-" + quantity; orderedTotQty += quantity; orderedItems[prodId] = quantity; } } } if($('#prow-' + itemId).size() == 1) { $('#prow-' + itemId).remove(); } $.cookie('order', order); $.cookie('orderedTotQty', orderedTotQty); showCart(false, 'removerow', itemId); }; //Emptying the cart var emptyCart = function() { var order = $.cookie('order'); order = ""; orderedTotQty = 0; orderedItems = null; orderedItems = new Array(); $.cookie('order', order); $.cookie('orderedTotQty', orderedTotQty); if($('[id^="prow-"]').size() > 0) { $('[id^="prow-"]').each(function(){ $(this).remove(); }); } showCart(false, 'empty'); }; //Displaying the cart items & calculations function showTotalPrice() { var cartHtml = ""; var total = 0; var shipping = 0; var grand_total = 0; var sub_total = 0; var shippingType = ''; var order = $.cookie('order'); orderedTotQty = $.cookie('orderedTotQty'); if($('#shippingCountry').val() == '') { shippingType = ''; } else if($('#shippingCountry').val() == 'US') { shippingType = 'US'; } else { shippingType = 'INTERNATIONAL'; } if (!order) { orderedTotQty = 0; } else { var items = order.split("|"); if(shipRates) { shipping = shipRates * 1.0; } for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (prodId != "" && quantity > 0) { sub_total = round((quantity * products[prodId][1]), 2); total += (quantity * products[prodId][1]); } } total = round(total, 2); } var snh = shipping + handling; //if(shipping == 0) { // snh = shipping; //} console.log(snh); grand_total = total + snh; $('#total-price').html('$ ' + total.toFixed(2)); $('#shipping-price').html('$ ' + snh.toFixed(2)); $('#grand-total').html('$ ' + grand_total.toFixed(2)); $("#paayAmount").val(total.toFixed(2)); }; // Refresh row content with updated quantity / price for a product function refreshRow(pid) { pid = parseInt(pid); quantity = orderedItems[pid]; sub_total = round((quantity * products[pid][1]), 2); $('#prow-' + pid + ' .tot-price').html('$' + sub_total.toFixed(2) + ' USD'); $('#prow-' + pid + ' .qtybox').val(quantity); $('#prow-' + pid + ' .dispqty').html(quantity); } //Displaying the cart items & calculations function showCart(showFullCart, act, itm) { var cartHtml = ""; var order = $.cookie('order'); orderedTotQty = $.cookie('orderedTotQty'); if (!order) { orderedTotQty = 0; if($('[id^="prow-"]').size() == 0) { $("#cartBox").html("

You have not selected any product...

  Browse Products"); } showTotalPrice(); return false; } else { var items = order.split("|"); var total = 0; var shipping = 0; var grand_total = 0; orderedTotQty = parseInt(orderedTotQty); //console.log('showFullCart'); //console.log(showFullCart); if (typeof showFullCart === "undefined") { return false; } else if(showFullCart == false) { if ((typeof act !== "undefined") && (typeof itm !== "undefined")) { if((act == 'add' || act == 'set' || act == 'remove') && itm > 0) { refreshRow(itm); } else if(act == 'removerow' && itm > 0) { itm = parseInt(itm); } } showTotalPrice(); return false; } orderedItems = null; orderedItems = new Array(); cartHtml += "
Order Summary Price
"; cartHtml += "
QtyUnit PriceTotal
"; var total = 0; for (var i = 0; i < items.length; i = i + 1) { var position = items[i].indexOf("-"); var prodId = items[i].substring(0, position); var quantity = parseInt(items[i].substring(position + 1)); if (prodId != "" && quantity > 0) { orderedItems[prodId] = quantity; var sub_total = round((quantity * products[prodId][1]), 2); total += sub_total; cartHtml += "
" + "
" + "

" + products[prodId][4] + " "+ quantity +"

" + "
" + "

" + products[prodId][0] + "

" + "

Qty: "+ quantity +"

" + "

$" + sub_total.toFixed(2) + "

" + "
" + "
" + "" + ""+ "
"+ quantity +"
" + "
$" + (products[prodId][1]).toFixed(2) + "
" + "
" } } cartHtml += "
"; cartHtml += "
" +"
" +"
    " +"
  • Sub Total: $" + total.toFixed(2) + "
  • " +"
  • Shipping & Handling: $0.00
  • " +"
  • Total: $" + total.toFixed(2) + "
  • " +"
" +"
" +"
"; cartHtml += "
" if (cartHtml != "") { $("#cartBox").html(cartHtml); $(".cart-box").html(cartHtml); $("#paayAmount").val(total.toFixed(2)); } else { $("#cartBox").html(" Loading..."); $(".cart-box").html('You have not selected any product... '); } return false; } }; var round = function(value, decimals) { return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); };