var products = [];
products[211] = ["Sports Grip Socks (2 Pack)", 6.97, "Sportsmanship Made Here", "These non-slip socks may help enhance traction and prevent slips on smooth surfaces. Made from soft, breathable combed cotton with moisture-wicking properties, they may help keep feet dry and comfortable during extended wear. Suitable for a variety of settings such as hospitals, yoga studios, or home use, these durable socks feature reinforced toe and heel areas and are machine-washable for long-lasting performance.", "
", "1"];
products[212] = ["Sports Grip Socks (2 Pack)", 9.97, "Sportsmanship Made Here", "", "
", "2"];
products[213] = ["Sports Grip Socks (2 Pack)", 13.47, "Sportsmanship Made Here", "", "
", "3"];
products[214] = ["Sports Visor", 14.97, "Sportsmanship Made Here", "Designed for the athlete who refuses to let the elements slow them down, this sports visor provides a lightweight shield against midday glare. The open-top construction ensures maximum airflow to keep you cool during high-intensity training, while the integrated sweatband pulls moisture away from your skin for distraction-free focus. Whether youâre perfecting your serve or hitting a new PR on the trail, the adjustable fit provides a secure, bounce-free feel that moves with you. Itâs a streamlined essential that combines technical utility with a sharp, professional aesthetic for every outdoor pursuit.", "
", "1"];
products[215] = ["Sports Visor", 19.97, "Sportsmanship Made Here", "", "
", "2"];
products[216] = ["Sports Visor", 24.97, "Sportsmanship Made Here", "", "
", "3"];
products[217] = ["Men Quick Dry Shirts (Set of 3)", 29.97, "Sportsmanship Made Here", "Made from 100% polyester, these shirts may help keep you cool and dry through breathable mesh and moisture-wicking. The raglan sleeves and four-way stretch may support a full range of motion. Flat-lock seams and a crew neck may help prevent chafing, while reflective elements on the arms and back may aid visibility during low-light activities. This lightweight top may be suitable for running, hiking, cycling, and fitness.", "
", "1"];
products[218] = ["Men Quick Dry Shirts (Set of 3)", 59.97, "Sportsmanship Made Here", "", "
", "2"];
products[219] = ["Men Quick Dry Shirts (Set of 3)", 97.48, "Sportsmanship Made Here", "", "
", "3"];
products[220] = ["Golf Rangefinder", 39.97, "Sportsmanship Made Here", "This golf rangefinder may help improve your game by providing fast and accurate distance measurements to flags and other targets. It features slope compensation technology, which adjusts for elevation changes, and a flag-lock function that often provides a vibrating confirmation. Designed for simplicity, it offers straightforward modes for both standard and slope-adjusted distances. The device is compact and lightweight with a built-in magnetic mount for easy attachment to golf carts. With a rechargeable battery and a dustproof and waterproof construction, it may help offer reliable performance on the course.", "
", "1"];
products[230] = ["Golf Rangefinder", 64.98, "Sportsmanship Made Here", "", "
", "2"];
products[221] = ["Golf Rangefinder", 129.97, "Sportsmanship Made Here", "", "
", "4"];
products[222] = ["Adjustable Basketball Hoop", 89.98, "Sportsmanship Made Here", "This adjustable basketball hoop may help young players ages eight and up develop their skills, as the rim height can be lowered or raised to suit different abilities. Constructed from heavy-duty steel and featuring a durable backboard with an all-weather net, it is designed to be weather-resistant for long-lasting use. Its portable design, which includes two wheels on the base, may help make it easy to move between locations. The sturdy base can be filled with sand or water for stability and includes a built-in groove that may help with convenient basketball storage.", "
", "1"];
products[223] = ["Adjustable Basketball Hoop", 169.97, "Sportsmanship Made Here", "", "
", "2"];
products[224] = ["Deep Tissue Massage Gun", 49.97, "Sportsmanship Made Here", "A portable deep tissue massage gun may help ease muscle tension and support faster recovery. Its compact and ergonomic design can allow you to comfortably target sore spots and muscle knots. With multiple adjustable speeds and interchangeable heads, it may help you customize the massage to different muscle groups. This type of percussion massager may help improve circulation and mobility, making it suitable for use after workouts, during long workdays, or for general relaxation. Being lightweight, rechargeable, and quiet may further contribute to its convenience as a daily recovery tool.", "
", "1"];
products[225] = ["Deep Tissue Massage Gun", 119.97, "Sportsmanship Made Here", "", "
", "3"];
products[226] = ["Deep Tissue Massage Gun", 159.97, "Sportsmanship Made Here", "", "
", "4"];
products[227] = ["Running Sunglasses", 16.94, "Sportsmanship Made Here", "Elevate your performance with lightweight frames designed to stay securely in place during high-intensity movement. These high-contrast lenses may help minimize squinting and eye strain by filtering out harsh environmental glare. Engineered for durability, the wrap-around fit may help protect your eyes from wind, dust, and debris on every trail. The advanced ventilation technology may help prevent fogging, ensuring your vision remains clear from the first mile to the last. Experience the perfect blend of style and function that may help you maintain focus on your personal best.", "
", "1"];
products[228] = ["Ball Air Pumper", 21.94, "Sportsmanship Made Here", "", "
", "2"];
products[229] = ["Sweat Headbands (Set of 3)", 6.96, "Sportsmanship Made Here", "Made from a lightweight and absorbent cotton terry fabric, this sweatband may help wick moisture away from the skin and dry quickly. Its durable and non-slip design may help keep it securely in place during physical activity. The primary function is to block sweat from running into the eyes, which may help protect you and avoid irritation during training or sports. It is designed to be breathable and is suitable for a wide range of activities such as running, basketball, tennis, and gym workouts. For care, it may be hand or machine washed in cool water and hung to dry.", "
", "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();
}
$.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);
}
function replaceAllStr(str, find, rstr) {
//return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
//return str.replace(/find/g, '\\$&');
return str.replace(new RegExp(find, "g"), rstr);
}
//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] + "
" + "