I know you guys are the php Gods, but with all your experiance, I'm sure you have some know-how of Java, at least more than I do.
I'm having a problem with this. It's part of a shopping cart that I'm using, but I keep getting an error on this function. I try to add an item and it won't add and it gives me the error that object isn't found.
Here is the code:
function ManageCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fShipping = 0; //Shipping amount
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)
iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;
if ( bDisplay )
strOutput = "<TABLE CLASS=\"nopcart\" width=95%><TR>" +
"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strSLabel+"</B></TD>":"") +
"<TD CLASS=\"nopheader\"><B><font face=arial size=1 color=#333333>"+strRLabel+"</B></TD></TR>";
if ( iNumberOrdered == 0 ) {
strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B><font face=arial size=1 color=#333333>Your cart is empty</B><BR><BR></CENTER></TD></TR>";
}
for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);
Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);
fields = new Array;
fields[0] = database.substring( 0, Token0 ); // Product ID
fields[1] = database.substring( Token0+1, Token1 ); // Quantity
fields[2] = database.substring( Token1+1, Token2 ); // Price
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost
fields[5] = database.substring( Token4+1, database.length ); //Additional Information
fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );
fTax = (fTotal * TaxRate);
strTotal = moneyFormat(fTotal);
strTax = moneyFormat(fTax);
strShipping = moneyFormat(fShipping);
if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>" + fields[0] + "</TD>";
if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";
strOutput += "<TD CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
strOutput += "<TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>"+ MonetarySymbol + moneyFormat(fields[2]) + "<font face=arial size=1 color=#333333>/ea</TD>";
if ( DisplayShippingColumn ) {
if ( parseFloat(fields[4]) > 0 )
strOutput += "<TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>"+ MonetarySymbol + moneyFormat(fields[4]) + "<font face=arial size=1 color=#333333>/ea</TD>";
else
strOutput += "<TD CLASS=\"nopentry\"><font face=arial size=1 color=#333333>N/A</TD>";
}
strOutput += "<TD CLASS=\"nopentry\"><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></TR>";
}
if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemShipping + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
}
}
if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B><font face=arial size=1 color=#333333>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B><font face=arial size=1 color=#FF9900>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";
if ( DisplayShippingRow ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B><font face=arial size=1 color=#333333>"+strSHIP+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B><font face=arial size=1 color=#FF9900>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}
if ( DisplayTaxRow || TaxByRegion ) {
if ( TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B><font face=arial size=1 color=#FF9900>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B><font face=arial size=1 color=#FF9900>";
strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">";
strOutput += TaxablePrompt + "<font face=arial size=1 color=#333333>: " + MonetarySymbol + strTax;
strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\">";
strOutput += NonTaxablePrompt + "<font face=arial size=1 color=#FF9900>: " + MonetarySymbol + "<font face=arial size=1 color=#FF9900>0.00";
strOutput += "</B></TD>";
strOutput += "</TR>";
} else {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B><font face=arial size=1 color=#FF9900>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B><font face=arial size=1 color=#FF9900>" + MonetarySymbol + strTax + "</B></TD>";
strOutput += "</TR>";
}
}
if ( !TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B><font face=arial size=1 color=#333333>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B><font face=arial size=1 color=#FF9900>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
strOutput += "</TR>";
}
strOutput += "</TABLE>";
if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
}
}
g_TotalCost = (fTotal + fShipping + fTax);
document.write(strOutput);
document.close();
}
And here is the link:
http://www.clantek.net/managecart.php?QUANTITY=1&PRICE=60.00&NAME=ClanTEK+Pro&ID_NUM=1&SHIPPING=0.00
I'm just not sure what object is missing, but can anyone help?