var products = []; products[211] = ["Athletic Tape (5 Pack)", 6.97, "Sportsmanship Made Here", "This athletic tape is made from 100% natural cotton and is latex-free. It may help to reduce tissue stress and provide support to joints during physical activity. The tape is very strong, yet can be easily torn by hand without scissors for convenient use. It is made with a special adhesive that provides a secure hold designed to leave no sticky residue on the skin. The breathable and skin-friendly material is suitable for a variety of uses such as securing hockey sticks, climbing, or providing support for wrists and other joints. It comes in a pack of five rolls, each measuring 1.5 inches by 10 yards, in packaging that is easy to carry.", "", "1"]; products[212] = ["Athletic Tape (5 Pack)", 9.97, "Sportsmanship Made Here", "", "", "2"]; products[213] = ["Athletic Tape (5 Pack)", 13.47, "Sportsmanship Made Here", "", "", "3"]; products[214] = ["Large Insulated Water Bottle", 14.97, "Sportsmanship Made Here", "This stainless steel water bottle may help maintain your preferred beverage temperature, keeping drinks hot for hours or cold for an entire day. Its advanced vacuum insulation makes it suitable for a variety of activities, from intense workouts to outdoor excursions. Constructed from durable, rust-proof materials with a non-slip grip, the bottle features a wide mouth for easy filling and cleaning. It comes with multiple leak-proof lids, such as a straw lid or a spout lid, which can allow for convenient one-handed use. Available in several sizes and colors, it may help you stay hydrated in many different situations.", "", "1"]; products[215] = ["Large Insulated Water Bottle", 19.97, "Sportsmanship Made Here", "", "", "2"]; products[216] = ["Large Insulated Water Bottle", 24.97, "Sportsmanship Made Here", "", "", "3"]; products[217] = ["Pickleball Set", 29.97, "Sportsmanship Made Here", "These outdoor pickleballs are made from high-quality plastic and feature a seamless design with 40 precisely drilled holes. This construction may help provide greater stability, durability, and consistent flight, even when used repeatedly. The balls offer high elasticity for a reliable bounce and come in high-visibility colors to help with tracking in various light conditions. Sold in a convenient pack of 20 with a storage bag, they are designed to be suitable for players of all skill levels and are intended for use on any outdoor court.", "", "1"]; products[218] = ["Pickleball Set", 59.97, "Sportsmanship Made Here", "", "", "2"]; products[219] = ["Pickleball Set", 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[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] = ["Ball Air Pumper", 16.94, "Sportsmanship Made Here", "This portable ball pump may help quickly and easily inflate sports equipment to a precise pressure with the press of a button. It can automatically detect the current pressure and reach a target pressure with a high degree of accuracy. Featuring several preset modes for different ball types and a custom setting, it may help simplify the inflation process. The device also includes a deflation feature, which may help save space during travel or storage. With its durable construction and a compartment for storing needles, this pump may be a convenient tool for coaches, players, and families.", "", "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 += "
ProductPrice Qty.Total
"; var total = 0; var term_htm =''; 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] + " " + products[prodId][0] + "

" + "
" + "" + "" + "
$" + (products[prodId][1]).toFixed(2) + "
" + "
" + products[prodId][5] + "
" + "
$" + sub_total.toFixed(2) + "
" + "
" } } cartHtml += ""; cartHtml += "
" +"
" +"" +"
" +"
"; cartHtml += "
" +"Continue Shopping Empty Cart Proceed To Checkout
" +"
"; cartHtml += ""; if (cartHtml != "") { $("#cartBox").html(cartHtml); $(".tot-prc").html('$' + total.toFixed(2)); } else { $("#cartBox").html(" Loading..."); } return false; } }; var round = function(value, decimals) { return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); };