var products = []; products[210] = ["Yoga Mat", 17.49, "Train Play Dominate", "Unroll peace, comfort, and support with every session. Whether you're deepening your practice or finding your first stretch, this yoga mat may help elevate your experience. Lightweight, durable, and non-slip, it offers the perfect foundation that may help guide you through your journey from sunrise stretches to evening relaxation.", "", "Yoga Mat", ""]; products[211] = ["Baseball Glove", 52.47, "Train Play Dominate", "Crafted for precision and comfort, this baseball glove is designed to fit your hand like a second skin. Whether you're making game changing catches or practicing your throws, it may help enhance your grip, control, and performance. Built to last with durable leather and a flexible fit, this glove may help you take your game to the next level every inning, every play.", "", "Baseball Glove", ""]; products[212] = ["Climbing Harness & Gear Set", 120.08, "Train Play Dominate", "Designed with durable nylon and reinforced stitching, this climbing harness and gear set is built for strength and reliability. The adjustable straps may help ensure a custom and comfortable fit, providing security during your climbs. Depending on the configuration, the set may also include essential accessories like carabiners and a rope for added safety. This gear is made to provide the comfort and security you need for a safe and efficient climbing adventure.", "", "Climbing Harness & Gear Set", ""]; products[213] = ["Jump Rope", 11.49, "Train Play Dominate", "Designed for speed, comfort, and durability, this jump rope may help you elevate your fitness routine. Whether you’re working on cardio, agility, or coordination, each smooth rotation may help you build strength, endurance, and speed. Lightweight yet sturdy, it’s the perfect tool for a quick workout anywhere at home, the gym, or on the go.", "", "Jump Rope", ""]; products[214] = ["9 Person Instant Cabin Tent", 99.99, "Train Play Dominate", "This instant tent sets up in minutes thanks to its pre-attached, locking pole framework. The interior is spacious, measuring 14 by 9 feet with a 78-inch center height, offering ample room to sleep 4 people with gear or 9 without. It is built for weather protection with resistant fabric, a full-coverage rainfly, and sealed seams, a system reinforced by included guylines and stakes. For comfort and organization, it features interior storage pockets and a combination of ground vents with a mesh ceiling to optimize airflow.", "", "Camping Tent", ""]; products[215] = ["Tennis Balls", 8.99, "Train Play Dominate", "Engineered for consistent bounce, durability, and precision, our tennis balls help you maintain control and focus. Perfect for training or competition, they deliver long-lasting performance match after match.", "", "Tennis Balls", ""]; products[216] = ["Soccer Cleats", 35.96, "Train Play Dominate", "These soccer cleats may help elevate your performance on the field. Designed for a comfortable fit for players of all ages and available in various sizes, their superior traction and lightweight construction may help improve your speed and control throughout the game. With superior traction and a lightweight fit, you’ll stay quick, confident, and ready for every play.", "", "Soccer Cleats", ""]; products[217] = ["Badminton Set", 26.97, "Train Play Dominate", "This badminton set may help players of all levels enjoy a fun and active game. The rackets, crafted from lightweight yet durable materials like aluminum or carbon fiber, feature a non-slip grip for secure handling. Paired with either feather or nylon shuttlecocks designed for consistent flight and durability, this set may help provide an enjoyable experience, whether you're playing a casual game in the backyard or a more competitive match.", "", "Badminton Set", ""]; products[218] = ["Goggle with Nose Cover", 17.98, "Train Play Dominate", "Our goggles with a built-in nose cover provide full-face protection, keeping you safe and comfortable in any environment. Perfect for swimming, diving, or any water activity, they may help improve your focus and performance.", "", "Goggle with Nose Cover", ""]; products[219] = ["Basketball", 34.98, "Train Play Dominate", "This durable Basketball may help you elevate your game, whether indoors or out. Crafted from durable rubber, its textured surface may help provide superior grip and control, while its engineered consistent bounce meets official game standards, making it perfect for players of all levels.", "", "Basketball", ""]; products[220] = ["Golf Putter", 69.96, "Train Play Dominate", "This high-performance Golf Putter may help you enhance your putting game, offering greater accuracy and consistency on the green. Crafted from durable Aluminum, it features a well-balanced head for improved stability and control, complemented by a soft, non-slip grip for added comfort during play.", "", "Golf Putter", ""]; products[221] = ["Hiking Stick", 239.94, "Train Play Dominate", "This lightweight Hiking Stick may help you find stability and support during your outdoor adventures. Crafted from durable aluminum, it's designed to withstand tough terrains while being adjustable for a comfortable, personalized fit. Its sleek black design makes it a stylish and practical accessory for all your hikes.", "", "Hiking Stick", ""]; products[222] = ["Drawstring Gym Bag", 9.95, "Train Play Dominate", "This drawstring backpack may help keep your gear organized and protected during workouts, travel, or outdoor activities. Made from water-resistant material with separate compartments for wet items and shoes, it offers both convenience and durability. Its spacious design and comfortable straps may assist in carrying essentials with ease while maintaining a stylish look.", "", "Drawstring Gym Bag", ""]; products[223] = ["Soft Play Volleyball", 12.98, "Train Play Dominate", "This Soft Play Volleyball may help enhance your game with its soft touch and durable design. Made with a sponge-backed synthetic leather cover and sturdy 18-panel construction, it offers comfort and long-lasting performance. Its reliable air retention and official size make it ideal for recreational play at the beach, park, or backyard.", "", "Hiking Stick", ""]; 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).length == 1) { $('#prow-' + itemId).remove(); $('#term-' + 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-"]').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)); }; // 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 += "
Order Summary Price
"; cartHtml += "
Order Summary QtyUnit PriceTotal
"; 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; termTxt = products[prodId][6]; termTxt = replaceAllStr(termTxt, ' __prc__', products[prodId][1].toFixed(2)); termTxt = replaceAllStr(termTxt, '__pname__', products[prodId][2]); termTxt = replaceAllStr(termTxt, '__prdname__', products[prodId][0]); term_htm += '' + termTxt + ''; cartHtml += "
" + "
" + "

" + products[prodId][4] + " " + products[prodId][0] + "

" + "
" + "" + ""+ "
"+ quantity +"
" + "
$" + (products[prodId][1]).toFixed(2) + "
" + "
$" + sub_total.toFixed(2) + "
" + "
" } } cartHtml += "
"; cartHtml += "
" +"
" +"
    " +"
  • Sub Total: $" + total.toFixed(2) + "
  • " +"
  • Shipping & Handling: $0.00
  • " +"
  • Total: $" + total.toFixed(2) + "
  • " +"
" +"
" +"
"; cartHtml += "
" if (cartHtml != "") { $("#cartBox").html(cartHtml); $(".trm_1").html(term_htm); } else { $("#cartBox").html(" Loading..."); } return false; } }; var round = function(value, decimals) { return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); };