var products = []; products[210] = ["Training Shorts - Black", 75, "CS Fitness Wear", "Designed to give you total confidence and comfort throughout your training, the Essentials Training Shorts are super-lightweight so you can fly through your workouts.

Fabric: 93% polyester 7% elastane", "", "Training Shorts - Black"]; products[211] = ["Protein Metal Shaker", 25, "CS Fitness Wear", "100% BPA Free, the stainless steel shaker is perfect for gym rats who are looking to shake up the perfect protein shake or superfood smoothie. While it's super functional & completely leak-proof, the steely design makes it look good on your gym bench too!", "", "Protein Metal Shaker"]; products[212] = ["Fitness Tracksuit Jacket", 135, "CS Fitness Wear", "The quintessential universal fitness jacket you can wear every day.. This lightweight, breathable jacket absorbs perspiration then wicks it away to the outer surface of the fabric for maximum comfort.

Fabric: 80% Polyester & 20% Cotton ", "", "Men's 2-in-1 Active Training Shorts "]; products[213] = ["Seamless Ultra Cycling Shorts", 75, "CS Fitness Wear", "Seamless texture panelling helps to contour your curves and the quick-drying fabric is designed to draw moisture away from the body and absorb sweat, making your workout more comfortable.

Fabric: 97% nylon 3% elastane", "", "Seamless Ultra Cycling Shorts"]; products[214] = ["Athletic Track Pants", 90, "CS Fitness Wear", "Looking for bottoms to work out in once in a while, or for everyday wear? This model is just for you. Excellent value for money!. Want to do fitness activities and be able to wear sporty bottoms every day? Who can stop you? With the durable woven fabric and loose fit, this is the perfect model for you.

Fabric: 100% Polyester", "", "Athletic Track Pants"]; products[215] = ["Slim Fit Track Pants", 90, "CS Fitness Wear", "For training regularly and reaching your goals. A fitted cut for this very stretchy model, which will follow you in all of your fitness activities thanks to a stretch insert between the legs made of very ventilated fabric.

Fabric: 100% Polyester", "", "Slim Fit Track Pants"]; products[216] = ["Slim Fit Gym Tights", 90, "CS Fitness Wear", "For training regularly and reaching your goals.. Ideal for regular training. Very stretchy yet durable fabric with elastane that wicks away perspiration and dries quickly.

Fabric: Synthetic", "", "Slim Fit Gym Tights"]; products[217] = ["Ultra Light Fitness Shorts", 65, "CS Fitness Wear", "For HIIT workout and circuit training enthusiasts. For those who always want to get in just one more rep.. Comfortable, lightweight seamless shorts with a wide elasticated waistband to meet all your needs.

Fabric: Synthetic", "", "Ultra Light Fitness Shorts"]; products[217] = ["Fitness Training T-Shirt", 85, "CS Fitness Wear", "Designed for training hard and looking great. If you want both style and comfort, then this seamless Fitness Training T-shirt was made for you. With its incredibly soft fabric, you'll want to wear it every day.

Fabric: 66% polyester 34% viscose", "", "Fitness Training T-Shirt"]; products[219] = ["Starter Gym Shorts", 65, "CS Fitness Wear", "For starting or getting back into fitness workouts.. Just because you're a beginner doesn't mean you don't need a technical product! These shorts are breathable, stretchy, and do everything you need from a pair of fitness shorts.

Fabric: Synthetic", "", "Starter Gym Shorts"]; products[220] = ["Training Tank Top", 55, "CS Fitness Wear", "For training regularly and reaching your goals. This model has a modern and sporty design. The stretchy, breathable fabric makes it a technical tank top that will help you reach your goals.

Fabric: Synthetic", "", "Training Tank Top"]; products[220] = ["Long Sleeves Gym T-Shirt", 95, "CS Fitness Wear", "For training regularly and reaching your goals.. Long-sleeved technical T-shirt: breathable and stretchy for 360° movement with a flattering style.

Fabric: 66% polyester 34% viscose", "", "Long Sleeves Gym T-Shirt"]; products[221] = ["Portable Gym Blender - Black", 30, "CS Fitness Wear", "This is definitely one of the hottest workout products of the year, the 100% portable gym blender lets you blend on the go, with its rechargeable battery set up. Just mix your fruits, powders, ice, veggies or anything and big-blend power will give you the perfect smoothie, juice & more.", "", "Portable Gym Blender - Black"]; products[222] = ["Portable Gym Blender - Blue", 30, "CS Fitness Wear", "This is definitely one of the hottest workout products of the year, the 100% portable gym blender lets you blend on the go, with its rechargeable battery set up. Just mix your fruits, powders, ice, veggies or anything and big-blend power will give you the perfect smoothie, juice & more.", "", "Portable Gym Blender - Blue"]; products[223] = ["Cross Back Sports Bra", 65, "CS Fitness Wear", "Stay supported in the Power Sports Bra, with removable cups and a breathable mesh back, you’ll be fit to fly through any workout. Featuring stay-dry, sweat-wicking technology, it will keep you cool and comfortable even through high-intensity workouts.

Fabric: 88% nylon 12% elastane", "", "Cross Back Sports Bra"]; products[224] = ["Training Drop Armhole Vest", 75, "CS Fitness Wear", "Have freedom to flex in our Drop Armhole Vest, created for a casual, loose-fitting layer, this workout essential features dropped armholes for room to breathe.

Fabric: 66% polyester 34% viscose", "", "Training Drop Armhole Vest "]; products[225] = ["High Waist Jersey Legging", 125, "CS Fitness Wear", "Our Essentials Leggings are made with cotton-rich, soft-touch fabric for easy, everyday wear. For additional comfort, we've designed these with a high-waisted wide waistband for a flattering fit that offers support.

Fabric: 95% cotton 5% elastane", "", "High Waist Jersey Legging"]; products[226] = ["Air Leggings", 125, "CS Fitness Wear", "Created especially for your cardio, you’ll be free to fly in our lightweight Air Leggings — with shape-enhancing panels and flatlock seams to keep you streamlined.", "", "Air Leggings "]; products[227] = ["Dropcut Sports Hoodie", 75, "CS Fitness Wear", "Created for superior comfort and style, our sports hoodie is cropped for an easy fit, making it a must have for your gym-kit as well as your lounge / rest days!

Fabric: 51% polyester 49% cotton", "", "Dropcut Sports Hoodie"]; products[228] = ["Shape Seamless Vest ", 75, "CS Fitness Wear", "Defining knit technology gets you curved to combat any workout, with the Shape Seamless Vest keeping sweat in style, in and out of the gym.

Fabric 54% nylon 36% polyester 10% elastic", "", "Shape Seamless Vest "]; products[229] = ["Power Leggings - Black", 125, "CS Fitness Wear", "The quick-drying fabric is treated with a hydrophilic finish, designed to draw moisture away from the body and absorb sweat, making your workout more comfortable. The fabric is also cotton-touch, so whilst it's made to perform, it's super-soft too.

Fabric: 88% nylon 12% elastane", "", "Power Leggings - Black"]; products[230] = ["Power Leggings - Mulberry", 125, "CS Fitness Wear", "The quick-drying fabric is treated with a hydrophilic finish, designed to draw moisture away from the body and absorb sweat, making your workout more comfortable. The fabric is also cotton-touch, so whilst it's made to perform, it's super-soft too.

Fabric: 88% nylon 12% elastane", "", "Power Leggings - Mulberry"]; products[231] = ["Portable Gym Blender - Green", 30, "CS Fitness Wear", "This is definitely one of the hottest workout products of the year, the 100% portable gym blender lets you blend on the go, with its rechargeable battery set up. Just mix your fruits, powders, ice, veggies or anything and big-blend power will give you the perfect smoothie, juice & more.", "", "Portable Gym Blender - Green"]; products[232] = ["Workout Headband", 10, "CS Fitness Wear", "The perfect headband to accompany your workouts, it ensures your hair is in place & your sweat is absorbed instantly. It is perfect for long sessions at the gym, running, cycling or playing your favorite sport. ", "", "Workout Headband"]; products[233] = ["Warm Hiking Socks ", 15, "CS Fitness Wear", "Our designers have developed this sock for your hikes in extremely cold weather. Enjoy the snow with the warmest in the range.. These ultra-warm socks will give you maximum warmth thanks to the foot knitted in 100% Merino wool. The ventilation in the instep promotes moisture transfer and drying.", "", "Warm Hiking Socks "]; products[234] = ["Ventilated Fitness Cap ", 20, "CS Fitness Wear", "The lightweight & ventilated cap is perfect for outdoor fitness enthusiasts to keep air circulation on while working out, hiking, running in intense heat. While being absolutely functional the design keeps you spot on when it comes to style.", "", "Ventilated Fitness Cap"]; console.log(products); var orderedItems = []; var orderedTotQty = 0; var maxQty = 100; 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)); }; // 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); 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 QtyUnit PriceTotal
"; var total = 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) { orderedItems[prodId] = quantity; var sub_total = round((quantity * products[prodId][1]), 2); total += sub_total; cartHtml += "
" + "
" + "

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

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