//NOTE: this code depends on dynamic js assignments in INCLUDES/queries/product_attributes_data.tpl function checkQty(form, product_id) { var qtyStr = form.elements["item_1_quantity"].value; qtyStr = qtyStr.replace(/^\s+|\s+$/g,""); if (qtyStr.length == 0 || isNaN(qtyStr)) { alert("A numeric quantity value must be entered."); return false; } else { return setPriceInfo(form, product_id, true); } } function setPriceInfo(form, product_id, doAlert) { var field_name; var elem; var attrStr = ''; var price; var freight_yn; var stockMsg; var regular_price; var selIdx; var allSelected = true; var attrVal = '' var regexpDoubleQuotes = new RegExp("""); var priceHTML = ''; var unselectedOptions = new Array(); var unselectedCounter = 0; var error_message = ''; var skuid = ''; field_name = "item_1_Color"; //alert("field_name=" + field_name); elem = form.elements[field_name]; if (elem.type == "select-one") { selIdx = elem.selectedIndex; if (selIdx) { attrVal = elem.options[selIdx].value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; //alert('fu1 =' + field_name + '-' + elem.options[selIdx].value); } else { unselectedOptions[unselectedCounter++] = "color"; //alert('fu2 =' + field_name + '-' + selIdx); } } else { attrVal = elem.value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; } field_name = "item_1_Size"; //alert("field_name=" + field_name); elem = form.elements[field_name]; if (elem.type == "select-one") { selIdx = elem.selectedIndex; if (selIdx) { attrVal = elem.options[selIdx].value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; //alert('fu1 =' + field_name + '-' + elem.options[selIdx].value); } else { unselectedOptions[unselectedCounter++] = "size"; //alert('fu2 =' + field_name + '-' + selIdx); } } else { attrVal = elem.value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; } field_name = "item_1_Style"; //alert("field_name=" + field_name); elem = form.elements[field_name]; if (elem.type == "select-one") { selIdx = elem.selectedIndex; if (selIdx) { attrVal = elem.options[selIdx].value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; //alert('fu1 =' + field_name + '-' + elem.options[selIdx].value); } else { unselectedOptions[unselectedCounter++] = "style"; //alert('fu2 =' + field_name + '-' + selIdx); } } else { attrVal = elem.value; attrVal.replace(regexpDoubleQuotes, '"'); attrStr += attrVal; } if (unselectedCounter) { if (doAlert) { error_message += "Please select "; for (i = 0; i < unselectedOptions.length; i++) { if (i > 0) { error_message += "/"; } error_message += unselectedOptions[i]; } error_message += " for item #" + product_id + ".\n"; alert(error_message); } //eval('sku_exists_' + product_id + ' = false;'); if (eval("default_regular_product_price_" + product_id)) { priceHTML += 'Was: ' + eval("default_regular_product_price_" + product_id) + '
'; priceHTML += 'Now: ' + eval("default_product_price_" + product_id) + ''; } else { priceHTML += '' + eval("default_product_price_" + product_id) + ''; } document.getElementById("priceInfo" + product_id).innerHTML = priceHTML; document.getElementById("stockMsg_" + product_id).innerHTML = ''; document.getElementById("skuID_" + product_id).innerHTML = 'Item# ' + product_id; return false; } else { //all existing attributes selected price = eval("prices_by_sku_" + product_id + "['" + attrStr + "']"); regular_price = eval("regular_prices_by_sku_" + product_id + "['" + attrStr + "']"); //alert("price=" + price + " prices_by_sku_" + product_id + "['" + attrStr + "']"); if (typeof(price) == 'undefined') { //exception! price not found for selected attributes //eval('sku_exists_' + product_id + ' = false;'); if (eval("default_regular_product_price_" + product_id)) { priceHTML += 'Was: ' + eval("default_regular_product_price_" + product_id) + '
'; priceHTML += 'Now: ' + eval("default_product_price_" + product_id) + ''; } else { priceHTML += '' + eval("default_product_price_" + product_id) + ''; } document.getElementById("priceInfo" + product_id).innerHTML = priceHTML; document.getElementById("stockMsg_" + product_id).innerHTML = ''; document.getElementById("skuID_" + product_id).innerHTML = 'Item# ' + product_id; alert("We're sorry, option selections incomplete or this product in the option(s) selected is not currently available. Please try another option(s)."); return false; } else { freight_yn = eval("freight_yn_by_sku_" + product_id + "['" + attrStr + "']"); form.elements["item_1_extra::freight_yn"].value = freight_yn; stockMsg = eval("stockMsg_by_sku_" + product_id + "['" + attrStr + "']"); document.getElementById("stockMsg_" + product_id).innerHTML = stockMsg; //added by greg wood skuid = eval("skuid_by_sku_" + product_id + "['" + attrStr + "']"); document.getElementById("skuID_" + product_id).innerHTML = 'Item# ' + skuid; //alert('freight_yn = ' + freight_yn); //price found for selected attributes //eval('sku_exists_' + product_id + ' = true;'); if (regular_price && regular_price != price) { priceHTML += 'Was: ' + regular_price + '
'; priceHTML += 'Now: ' + price + ''; } else { priceHTML += '' + price + ''; } document.getElementById("priceInfo" + product_id).innerHTML = priceHTML; if (eval("sku_discontinued_" + product_id + "['" + attrStr + "']")) { alert("We're sorry, this product in the option(s) selected is not currently available. Please try another option(s)."); return false; } else { return true; } } } }