Hi Guys,

At the moment we are running the below javascript on the shopping cart page of a website to stop customers purchasing under $500 worth of products. What we need is for the javascript to recognised a discount code entered and allow for purchases under $500 or to recognised a particular password or login used by a special user and then allow them to purchase under $500.

We tried to put an 'else if' under the 'if (intotal > 500) {
window.location=document.getElementById('catshopbuy').href;
}' and added a variable for the discout code on the <td> tag but this broke the shop and we could not checkout at all.


We also created and 'if' statement around the below code and said if the discount code was equal to the code we setup then ignore all the below script but this didnt work either.


Is this the correct way to go about it, are we missing something or is there an easier way to accomplish this?

Code:
<script>
function stay() {
var intotal=document.getElementById('intotal').innerHTML;
erro=0;
var k=document.getElementById("ShippingOptions");
if(k){if(k.value<1){document.getElementById('error_msg').innerHTML=Oshoplang.InvalidShip;erro=1;}}
var c=document.getElementById("shippingCountry");ccVal="";if(c){ccVal=c.value}var a=document.getElementById("shippingState");var l="";if(a){l=a

[a.selectedIndex].text;if(a.value<1){document.getElementById('error_msg').innerHTML=Oshoplang.ChooseState;erro=1;}}
var j=document.getElementById("shippingPostcode");var h="";if(j){h=j.value;if(j.value.length<1){document.getElementById

('error_msg').innerHTML=Oshoplang.EnterZip;erro=1;}}
var g=document.getElementById("shippingCalc");if(g){var b=false;var e=g.getElementsByTagName("input");if(e.length>0){for(var d=0;d<e.length;d++){if(e

[d].checked){b=true;break}}}if(!b){document.getElementById('error_msg').innerHTML=Oshoplang.ChooseShip;erro=1;}}

if (erro==1) {document.getElementById('error_msg').style.display="block";}
if (erro==0) {
intotal=parseFloat(intotal.substring(1).replace(/,/gi,"") );
if (intotal > 500) {
window.location=document.getElementById('catshopbuy').href;
}
else
{
document.getElementById('error_msg').innerHTML="ERROR - THE TOTAL AMOUNT OF YOUR ORDER IS BELOW $500";
document.getElementById('error_msg').style.display="block";
}

}
}
</script>
Any guidance would be great.
Thanks
Rachael