var items_in_cart; var is_Pro = false; function addthis() { //get the main parts var sku = document.getElementById("sku").value; var cost = document.getElementById("cost").value; var qty = document.getElementById("quantity").value; var o = new Object(); o._sku = sku; o._cost = cost; o._product_quantity = qty; return addTocart(o); } function addone(sku, cost) { var qty = 1; var o = new Object(); o._sku = sku; o._cost = cost; o._product_quantity = qty; return addTocart(o); } function addTocart(o) { //product_id = o.product_id; var product_quantity = o._product_quantity; var sku = o._sku; //family = o.family; var cost = o._cost; //estimated_tax = o.estimated_tax; //customer_id = o.customer_id; //customer_order_id = o.customer_order_id; //description = o.description; var args = { //product_id : product_id, product_quantity : product_quantity, //estimated_tax : estimated_tax, //customer_id : customer_id, sku : sku, //family : family, cost : cost} //customer_order_id : customer_order_id, //description : o.description } var retVal = "OK"; $.ajax({ type: "POST", url: "/cart/procartcount.asp", async : false, data: {}, success: function(data){ items_in_cart = data; } }); var OK = true; if (is_Pro) { if (parseInt(items_in_cart) >= 4) { retVal = "You have met your quota for tool purchases. Nothing more can be added to your cart."; OK = false; } } if (OK) { $.post("/cart/add2cart.asp", args, function(data) { updatecart(); } ); } return retVal; } function addArrayTocart(arrayOfItems) { for(i=0 ; i < arrayOfItems.length-1; i++) { o = arrayOfItems[i]; product_id = o.product_id; product_quantity = o.product_quantity; estimated_tax = o.estimated_tax; customer_id = o.customer_id; customer_order_id = o.customer_order_id; description = o.description; sku = o.sku; cost = o.cost; family = o.family; var args = {product_id : product_id, product_quantity : product_quantity, estimated_tax : estimated_tax, customer_id : customer_id, sku : sku, family : family, cost : cost, customer_order_id : customer_order_id, description : o.description } $.ajax({url:"/cart/add2cart.asp", data:(args), async:false}); } i = arrayOfItems.length -1; o = arrayOfItems[i]; product_id = o.product_id; product_quantity = o.product_quantity; estimated_tax = o.estimated_tax; customer_id = o.customer_id; customer_order_id = o.customer_order_id; description = o.description; var args = {product_id : product_id, product_quantity : product_quantity, estimated_tax : estimated_tax, customer_id : customer_id, customer_order_id : customer_order_id, description : o.description } $.post("/cart/add2cart.asp", args, function(data) { updatecart(); } ); return "OK"; } function updatecart() { $.post("/cart/cartcount.asp", {}, function(data) { if (data == "0") { $("#cct").html(""); } else { $("#cct").html(" (" + data + ")"); } } ); } function emptycart() { $.post("/cart/emptycart.asp", null, function(data){ window.location.reload()} ); } function removeitem(id) { $.post("/cart/removeitem.asp", { itemid : id }, function(data){ window.location.reload()} ); }