View Full Version : Business Catalyst Checkout Javascript

07-27-2011, 09:35 AM
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) {
}' 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?

function stay() {
var intotal=document.getElementById('intotal').innerHTML;
var k=document.getElementById("ShippingOptions");
var c=document.getElementById("shippingCountry");ccVal="";if(c){ccVal=c.value}var a=document.getElementById("shippingState");var l="";if(a){l=a

var j=document.getElementById("shippingPostcode");var h="";if(j){h=j.value;if(j.value.length<1){document.getElementById

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) {
document.getElementById('error_msg').innerHTML="ERROR - THE TOTAL AMOUNT OF YOUR ORDER IS BELOW $500";


Any guidance would be great.