/////////////////////////////// // reference this file in the head section of each website them var ArrayAllowedShippingMethodIds = new Array() function isAllowed(ShippingMethodId) { for (var i=0;i< ArrayAllowedShippingMethodIds.length;i++) { if( ShippingMethodId == ArrayAllowedShippingMethodIds[i] ){ return 1 } } return 0 } function NotOurPage() { var title = document.title if( title.search(/Shipping Method/) == 0 || title.search(/Review and Submit/) == 0 ) { return 0 } else { return 1 } } function AllowShippingMethods( list ) { if( NotOurPage() ){ return } //document.write("
Shipping Method Operating on this page v3") //http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions:arguments ArrayAllowedShippingMethodIds = Array.prototype.slice.call(arguments) var ArrayShippingMethods = document.getElementsByName("sShipMeth") var ZapThese = new Array() for (var i=0;i< ArrayShippingMethods.length;i++) { var ShippingMethodId = ArrayShippingMethods[i].value if( isAllowed( ShippingMethodId ) == 0 ) { ZapThese.push(ArrayShippingMethods[i].parentNode) } } for (var i=0;i< ZapThese.length;i++) { ZapThese[i].innerHTML ='' } } // the following line is the trigger for the above code. Put in the body section of the website theme // AllowShippingMethods("20010", "20011", "20014") // function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } // end of function CurrencyFormatted() // ran into problems with lastChild in FireFox and Safari 3 // so I wrote my own version function myLastChild(object) { index = object.length - 1 return index } function RemoveShippingRowFromCart() { if( document.title.search(/Shopping Cart/) != 0 ){ return } var ShippingRow = document.getElementById("ordersummary_estship") var ShippingAmount = ShippingRow.cells[1].innerHTML.substr(1) // var TotalRow = ShippingRow.parentNode.lastChild // see myLast Child definition as to why we are not using // built in function lastChild here. var index = myLastChild( ShippingRow.parentNode.rows ) var TotalRow = ShippingRow.parentNode.rows[index] var TotalCell = TotalRow.cells[4].firstChild var TotalAmount = TotalCell.innerHTML.substr(1) //document.write( ShippingAmount ) TotalCell.innerHTML = "$" + CurrencyFormatted(TotalAmount - ShippingAmount) ShippingRow.parentNode.removeChild(ShippingRow) } //RemoveShippingRowFromCart() function ForceShippingRulesInCart() { if( document.title.search(/Shopping Cart/) != 0 ){ return } var ShippingRow = document.getElementById("ordersummary_estship") var ShippingAmount = ShippingRow.cells[1].innerHTML.substr(1) ShippingRow.cells[1].innerHTML = "$0.00" ShippingRow.cells[0].innerHTML = "FREE SHIPPING ON ALL ORDERS" var index = myLastChild( ShippingRow.parentNode.rows ) var TotalRow = ShippingRow.parentNode.rows[index] var TotalCell = TotalRow.cells[4].firstChild var TotalAmount = TotalCell.innerHTML.substr(1) - ShippingAmount //document.write( ShippingAmount ) TotalCell.innerHTML = "$" + CurrencyFormatted(TotalAmount) var LowAmountWarningCell = TotalRow.cells[2] if( TotalAmount < 500 ) { LowAmountWarningCell.innerHTML = "Your order is below the minimum order amount of $500.00" //document.getElementById("checkout").style.visibility = "hidden" document.getElementById("checkout").disabled=true } } //ForceShippingRulesInCart() ///////////////////////////////