/*----------------------------------------------------------------------------- * Javascript Functions *----------------------------------------------------------------------------- * stock_levels.js *----------------------------------------------------------------------------- * Author: Estelle Winterflood * Email: cubecart@expandingbrain.com * Store: http://cubecart.expandingbrain.com * * Date: October 31, 2006 * Updated: May 19, 2008 * Compatible with CubeCart Version: 4.x.x *----------------------------------------------------------------------------- * SOFTWARE LICENSE AGREEMENT: * You must own a valid license for this modification to use it on your * CubeCart™ store. Licenses for this modification can be purchased from * Estelle Winterflood using the URL above. One license permits you to install * this modification on a single CubeCart installation only. This non-exclusive * license grants you certain rights to use the modification and is not an * agreement for sale of the modification or any portion of it. The * modification and accompanied documentation may not be sublicensed, sold, * leased, rented, lent, or given away to another person or entity. This * modification and accompanied documentation is the intellectual property of * Estelle Winterflood. *----------------------------------------------------------------------------- * DISCLAIMER: * The modification is provided on an "AS IS" basis, without warranty of * any kind, including without limitation the warranties of merchantability, * fitness for a particular purpose and non-infringement. The entire risk * as to the quality and performance of the Software is borne by you. * Should the modification prove defective, you and not the author assume * the entire cost of any service and repair. *----------------------------------------------------------------------------- */ function ale(f){var old = window.onload;if (typeof window.onload != 'function') {window.onload = f;} else {window.onload = function() {old();f();}}}function st(e,t){if(e) {e.innerText = t;e.textContent = t;}}function gv(o){var a = [];for(var i=0; i 0) index += ','; index += sl_validAssignIds[i]; } } } return index; } function updateStockLevel() { if (!checkInstallation()) { return; } var assignIds = []; var stockString = ''; var outStockString = ''; var prodCode = ''; var a = gv(sl_elements); var incompleteSelection = false; for (var i=0; i 0) { // this product variant is in stock stockString = sl_langInStock; if (sl_showStockLevel) stockString += ': ' + stockLevel; outStockString = ''; } else { // this product variant is sold out stockString = ''; outStockString = sl_langVariantOutOfStock; } } else if (typeof stockLevel == 'undefined') { // this product variant is not available stockString = ''; outStockString = sl_langVariantNotAvail; } var inStockSpan = document.getElementById('inStock'); var outOfStockSpan = document.getElementById('outOfStock'); var prodCodeSpan = document.getElementById('prodCode'); sh(inStockSpan, stockString); sh(outOfStockSpan, outStockString); if (prodCode != '' && sl_appendCode) { st(prodCodeSpan, sl_prodCode+sl_appendChar+prodCode); } else if (prodCode != '' && !sl_appendCode) { st(prodCodeSpan, prodCode); } else { st(prodCodeSpan, sl_prodCode); } } function checkStock() { if (!checkInstallation(true)) { return true; } var a = gv(sl_elements); var index = getIndex(a); if (typeof sl_stockInfo[index] != 'undefined') { stockLevel = sl_stockInfo[index][0]; } else if (index == '') { stockLevel = sl_totalStock; } if (typeof stockLevel != 'undefined') { if (stockLevel > 0) { // in stock return true; } else if (stockLevel <= 0 && !sl_useStock) { // this product ignores stock levels entirely (except for 'never available' variants) return true; } else if (stockLevel <= 0 && sl_allowOutOfStock) { // out of stock, out of stock purchases ARE permitted return true; } else if (stockLevel <= 0 && !sl_allowOutOfStock) { // out of stock, out of stock purchases NOT permitted alert(sl_langOutOfStockAlert); return false; } } else { // this size/colour/etc marked as "never available" alert(sl_langNotAvailAlert); return false; } }