var products = [];
products[210] = ["USB C Adapter OTG Cable Kit", 9.95, "New Bright Edge Connection", "The USB-C Adapter OTG Cable Kit may help you unlock the full potential of your USB-C devices. This all-in-one kit may help provide the versatility to connect a wide range of peripherals to your tablet, smartphone, laptop, or other USB-C-enabled devices. It may help offer a simple, reliable solution for transferring files, connecting external devices, or expanding your device's functionality.", "", "X 1"];
products[211] = ["USB C Adapter OTG Cable Kit", 14.95, "New Bright Edge Connection", "", "
", "X 2"];
products[212] = ["Charging Station for Multiple Device", 6.95, "New Bright Edge Connection", "This compact USB-A charging station may help you neatly charge up to 6 devices simultaneously, offering a tidy solution to cable clutter. It comes with 6 cables, a smart watch charger holder (cable not included), and a Type-A to Type-C adapter. Delivering a maximum output of 2.4A per port, it may charge devices up to 80% faster than standard 2A chargers.", "
", "X 1"];
products[213] = ["Charging Station for Multiple Device", 11.9, "New Bright Edge Connection", "", "
", "X 2"];
products[214] = ["Charging Station for Multiple Device", 19.95, "New Bright Edge Connection", "", "
", "X 3"];
products[215] = ["Language Translator Device Scanner Pen", 34.95, "New Bright Edge Connection", "This powerful scanning pen boasts features like text translation, voice translation, and intelligent recording. It rapidly translates entire lines of text with high accuracy (up to 98%) and supports online and offline translation for over 60 languages. This translation pen features a user-friendly touchscreen interface. Easily translate online via Wi-Fi or offline, and enjoy worry-free scanning thanks to the plastic scanning port that won't damage delicate paper and is compact and portable for travel, study, and work.", "
", "X 1"];
products[216] = ["Language Translator Device Scanner Pen", 59.9, "New Bright Edge Connection", "", "
", "X 2"];
products[217] = ["Mini Bluetooth Projector ", 39.95, "New Bright Edge Connection", "Take your entertainment anywhere with the Mini Bluetooth Projector. Compact, portable, and powerful, this pocket-sized projector may deliver stunning visuals and immersive sound wherever you go. Whether youâre watching movies, playing games, presenting at work, or enjoying a family night at home, this projector may turn any space into a theater experience.", "
", "X 1"];
products[218] = ["Mini Bluetooth Projector ", 77.96, "New Bright Edge Connection", "", "
", "X 2"];
products[219] = ["Mini Bluetooth Projector", 124.95, "New Bright Edge Connection", "", "
", "X 4"];
products[220] = ["Mini Bluetooth Projector", 154.95, "New Bright Edge Connection", "", "
", "X 5"];
products[221] = ["Soundbar", 74.97, "New Bright Edge Connection", "This sound system delivers vibrant bass, crystal clear dialogue, and a panoramic soundstage, and may help you experience a 3D surround sound effect with Dolby Atmos. You can stream music, radio, podcasts, and audiobooks from your favorite services even when the TV is off. With a precisely perforated grille, the Beam is designed to look as good as it sounds and blends seamlessly into your home. Advanced audio processing may ensure balanced sound at any volume level, and for quieter viewing, the Night Sound feature may help by reducing intense effects and enhancing softer ones.", "
", "X 1"];
products[222] = ["Soundbar", 129.95, "New Bright Edge Connection", "", "
", "X 2"];
products[223] = ["Soundbar", 169.95, "New Bright Edge Connection", "", "
", "X 3"];
products[224] = ["Wireless Game Controller ", 49.95, "New Bright Edge Connection", "This PC gaming controller offers no drift for flawless control and features a 1000Hz polling rate for instant response, which may help with competitive gameplay. It boasts multi-platform compatibility across PC, Switch, iOS, and Android via various connection methods. With an 800mAh battery, it provides up to 15 hours of playtime. The controller also allows for customizable turbo and vibration settings and features dynamic RGB lighting with multiple colors and modes. Its durable gel buttons are designed for long-lasting performance.", "
", "X 1"];
products[225] = ["Wireless Game Controller ", 99.96, "New Bright Edge Connection", "", "
", "X 2"];
products[226] = ["Wireless Game Controller ", 169.95, "New Bright Edge Connection", "", "
", "X 4"];
products[227] = ["Smart Floor Lamp", 27.97, "New Bright Edge Connection", "This RGB floor lamp offers versatile control via a foot switch, remote, or smartphone app, which may help you easily manage its 16 million colors, brightness, and color modes. The app also features DIY color selection and a music rhythm function that may help enhance parties. It may help you create the perfect ambiance with warm, natural, or cool white light. This lamp is perfect for various scenarios, from gatherings to movie nights, and its customizable lighting may help set the right mood for any occasion.", "
", "X 1"];
products[228] = ["Humidifier", 34.95, "New Bright Edge Connection", "This powerful humidifier features a 360° nozzle and 3-speed settings, which may help you easily control humidity and create a comforting indoor condensation level for skin soothing and easier breathing without over-humidifying. Designed with perfect humidity control in mind, it includes a humidistat that automatically adjusts levels, and may help with plant growth and preserving wood furniture. This humidifier also boasts convenient features like a large capacity, top-fill design, easy cleaning, and an automatic shut-off when water runs out.", "
", "X 1"];
console.log(products);
var orderedItems = [];
var orderedTotQty = 0;
var maxQty = 10;
var shipRates = false;
var handling = 0;
var carturl = "cart.php";
// Function to check item exists in cart
var checkItemExists = function(itemId) {
var order = $.cookie('order');
if (!order) {
return false;
} 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) {
return true;
}
}
}
return false;
}
//Funtion adds Items to Cart
var addItem = function(itemId, Qty, showFullCart) {
if (typeof showFullCart === "undefined") {
showFullCart = false;
}
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 (!order) {
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(showFullCart, '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, showFullCart) {
if (typeof showFullCart === "undefined") {
showFullCart = false;
}
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).length == 1) {
$('#prow-' + itemId).remove();
$('#term-' + itemId).remove();
}
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
showCart(true, '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-"]').length > 0) {
$('[id^="prow-"]').each(function(){
$(this).remove();
});
}
$('.trm_1').hide();
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));
$(".tot-prc").html('$' + 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-"]').length == 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); 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 += "" + products[prodId][4] + " " + products[prodId][0] + " " + products[prodId][5] + "
" + "