/** * Set up multiple Order Now button mechanisms on one page. * * Calls setupProductOptions(variableSuffix). */ function setupMultipleProductOptions(variableSuffixes) { if (variableSuffixes && typeof(variableSuffixes) !== 'undefined' && variableSuffixes.length && typeof(variableSuffixes.length) !== 'undefined' && variableSuffixes.length > 0) { for (i=0; i * * * Default message goes here. * * * * @param variableSuffix Suffix to append to the element ID values above. * For example, if suffix is "_test", then the productsSelectHolder * ID value would become "productsSelectHolder_test". The suffix is * also appended to the array names (productNames and productUrls), * so it is important that the arrays are passed back from Shopfront * with the correct names. */ function setupProductOptions(variableSuffix) { // Fix parameter values and setup local variables. if (!variableSuffix || typeof(variableSuffix) === "undefined") { variableSuffix = ""; } else { eval("productNames = typeof(productNames" + variableSuffix + ") === 'undefined' ? new Array() : productNames" + variableSuffix); eval("productUrls = typeof(productUrls" + variableSuffix + ") === 'undefined' ? new Array() : productUrls" + variableSuffix); } // Check the document structure. var productsSelectHolder = document.getElementById("productsSelectHolder" + variableSuffix); var productsSelectBox = document.getElementById("productsSelectBox" + variableSuffix); var orderNowButtonHolder = document.getElementById("orderNowButtonHolder" + variableSuffix); if (typeof(productsSelectHolder) === 'undefined' || typeof(productsSelectBox) === 'undefined' || typeof(orderNowButtonHolder) === 'undefined') { // The document structure is incorrect. The best we can do is... return; } var orderNowButtonHTML = 'Order Now\n'; // Check for the required global variables. if (typeof(productNames) === 'undefined' || typeof(productUrls) === 'undefined' || productNames.length === 0 || productUrls.length === 0) { // Either the service is down, or the database is broken. // In either case, we aren't getting any products, so disable everything. // This will hide both the select box and the Order Now button. productsSelectHolder.innerHTML = 'No Products Available'; orderNowButtonHolder.innerHTML = ''; showOutageMessage(); } else if (productNames.length <= 1 || productUrls.length <= 1) { productsSelectHolder.innerHTML = ''; orderNowButtonHolder.innerHTML = orderNowButtonHTML; } else { // There is more than one product, so we need a select box. // Create the Option objects and assign them to the