var products = [];
products[211] = ["Color Chalk (24 Pack)", 9.82, "Best Bet Selection", "Our versatile Color Chalks are perfect for several creative projects, offering smooth, clean lines on surfaces like children's chalkboards, construction paper, cardboard boxes, and paper bags. Ensuring you have an ample supply to encourage hours of artistic expression and learning. ", "
", "X 1"];
products[212] = ["Small Storage Bins (Set of 3)", 19.82, "Best Bet Selection", "This set of three handcrafted woven rope baskets may help you effortlessly organize a variety of everyday itemsâeach basket offers enough room to hold books, clothing, baby essentials, or toys. Made from soft, odor-free natural cotton rope, the design may help create a safer space for children, free from sharp edges or harsh materials. Hidden reinforced handles allow for easy lifting and placement, which may help simplify gift-giving for occasions like birthdays, holidays, or housewarmings. With classic colors and a timeless woven texture, these baskets may help bring a warm, cohesive look to any room while keeping daily essentials neatly within reach.", "
", "X 1"];
products[213] = ["Small Storage Bins (Set of 3)", 49.82, "Best Bet Selection", "", "
", "X 3"];
products[214] = ["Storage Bins (Set of 3)", 79.82, "Best Bet Selection", "These collapsible storage bins, featuring dual carrying handles, may help make transporting heavy loads easier while maintaining their shape due to the sturdy fabric. The breathable, foldable design may help provide an attractive storage solution for organizing a wide range of items, which can maximize your space and help you reduce clutter.", "
", "X 3"];
products[215] = ["Storage Bins (Set of 3)", 97.82, "Best Bet Selection", "", "
", "X 4"];
products[216] = ["Storage Bins (Set of 3)", 119.82, "Best Bet Selection", "", "
", "X 5"];
products[217] = ["Storage Bins (Set of 3)", 139.82, "Best Bet Selection", "", "
", "X 6"];
products[218] = ["Balloon Arch Kit (Set of 2)", 39.82, "Best Bet Selection", "This adaptable balloon arch is designed for a custom fit, as its height and width may be adjusted simply by changing the distance between the bases. Its durable construction from thick PVC and fiberglass allows for 130 pound weight capacity, meaning it may be safely reused for over 50 events.", "
", "X 1"];
products[219] = ["Balloon Arch Kit (Set of 2)", 69.82, "Best Bet Selection", "", "
", "X 2"];
products[220] = ["Balloon Arch Kit (Set of 2)", 125.82, "Best Bet Selection", "", "
", "X 4"];
products[221] = ["Balloon Arch Kit (Set of 2)", 159.82, "Best Bet Selection", "", "
", "X 5"];
products[222] = ["Balloon Arch Kit (Set of 2)", 179.82, "Best Bet Selection", "", "
", "X 6"];
products[223] = ["Balloon Arch Kit (Set of 2)", 214.82, "Best Bet Selection", "", "
", "X 8"];
products[224] = ["Balloon Arch Kit (Set of 2)", 238.82, "Best Bet Selection", "", "
", "X 9"];
products[225] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 59.82, "Best Bet Selection", "This 16-piece travel toiletry set, which includes various bottles, jars, and accessories inside a clear zipper bag, may help you maintain an organized and stress-free packing routine. The 3-layer anti-leakage design and no-drip valves may help prevent messy spills inside your luggage, while the 3oz container sizes may help you meet airline security requirements for carry-on liquids. Furthermore, the wide-mouth design of the bottles may help simplify the refilling and cleaning process, making this set a practical solution for vacations, business trips, or camping.", "
", "X 1"];
products[226] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 107.82, "Best Bet Selection", "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 2"];
products[227] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 149.82, "Best Bet Selection", "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 3"];
products[228] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 199.82, "Best Bet Selection", "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 4"];
products[229] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 249.82, "Best Bet Selection", "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 5"];
products[230] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 268.82, "Best Bet Selection", "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 6"];
products[231] = ["Travel Size Toiletries Bottles 16 Pieces (Set of 3)", 299.82, "Best Bet Selection", "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 7"];
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 (!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(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));
$(".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-"]').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 += "" + products[prodId][4] + " " + products[prodId][0] + ""+ products[prodId][5] +"
" + "