Tax and Total not showing up on checkout. Displays $NaN.aN

Problems installing or using the NOP Design Free Shopping Cart that do not fit into one of the above categories.

Moderators: Koibito, Stefko, Randy

Postby zubial » Fri Apr 01, 2005 4:54 pm

Thank you randy,
but where should I change the code in the nopcart.js
I suppose in checkoutCart ? but the line ??

[[[ The next part:

Quote:

If you still get a NaN...try this

alert (fTotal + ' ' + fTax + ' ' + fShipping) ;
fTax += 1;
fTotal +=1;
fShipping += 1;
alert (fTotal + ' ' + fTax + ' ' + fShipping) ;




That will show up any NaNs in the math...you can also use the if statement(s):


Code:


   if ( isNaN(fTax) )        alert( 'fTax is Not A Number' );
   if ( isNaN(fShipping) )   alert( 'fShipping is Not A Number' );
   if ( isNaN(fTotal) )      alert( 'fTotal is Not A Number' );

]]]]

<<<<<
//---------------------------------------------------------------------||
// FUNCTION: CheckoutCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page for ||
// checkout. ||
//---------------------------------------------------------------------||
function CheckoutCart( ) {
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)
var strPP = ""; //Payment Processor Description Field

iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;

if ( TaxByRegion ) {
QueryString_Parse();
fTax = parseFloat( QueryString( OutputOrderTax ) );
strTax = moneyFormat(fTax);
}

if ( bDisplay )
strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></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]) );
if (fTotal >= 100)
fShipping = 0;
else
fShipping = 5.95;
if ( !TaxByRegion ) fTax = (fTotal * TaxRate);
strTotal = moneyFormat(fTotal);
if ( !TaxByRegion ) strTax = moneyFormat(fTax);
strShipping = moneyFormat(fShipping);

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";

if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

strOutput += "<TD CLASS=\"nopentry\">" + fields[1] + "</TD>";
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ unit.</TD>";

if ( DisplayShippingColumn ) {
if ( parseFloat(fields[4]) > 0 )
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ unit.</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
}

strOutput += "</TR>";
}

if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( PaymentProcessor != '' ) {
//Process description field for payment processors instead of hidden values.
//Format Description of product as:
// ID, Name, Qty X
strPP += fields[0] + ", " + fields[3];
if ( fields[5] != "" )
strPP += " - " + fields[5];
strPP += ", Qty. " + fields[1] + "\n";
} else {
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=3><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";

if ( DisplayShippingRow ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}

if ( DisplayTaxRow || TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
strOutput += "</TR>";
}

strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
strOutput += "</TR>";

strOutput += "</TABLE>";


if ( PaymentProcessor == 'an') {
//Process this for Authorize.net WebConnect
strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
} else if ( PaymentProcessor == 'wp') {
//Process this for WorldPay
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
} else if ( PaymentProcessor == 'lp') {
//Process this for LinkPoint
strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
} else {
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)) + "\">";
}
}

document.write(strOutput);
document.close();
}
????
thank you for your help.
zubial
zubial
 
Posts: 28
Joined: Sat Nov 22, 2003 11:47 am
Location: france

Postby Randy » Sun Apr 03, 2005 1:39 pm

Let's use this code:

Code: Select all
   if ( isNaN(fTax) )        alert( 'fTax is Not A Number' );
   if ( isNaN(fShipping) )   alert( 'fShipping is Not A Number' );
   if ( isNaN(fTotal) )      alert( 'fTotal is Not A Number' );


You can stick it anywhere you want to see what is happening with the variables in the function causing the problem. In this case checkoutCart.

I would place it just before the shipping row in the table totals, line 823 in the original nopcart.js file.

This will tell which variable is causing you grief.

If it is the tax variable, fTax, move the code up to line 738 this will determine if your tax is being properly parsed out of the URL.

If it is the shipping variable, put it in line 773.

All this will really do is isolate the variable causing the problem, and where the error is getting in...narrowing down the search more or less!

If you put the code in more than one place at a time, label the alert box with the line number.

You can always post the URL again so others can take a peek...

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

tax Nan error .. following

Postby zubial » Wed Apr 06, 2005 8:11 pm

Hi Randy,

the alert box give always the same results wherever youy put it :

fTax is not a number.

and now, what's up ? how to resolve it ?

thank you.

zubial

actual test url

http://www.zubialcompany.com/zubial/zes ... nopcart.js
http://www.zubialcompany.com/zubial/zes ... index.html
zubial
 
Posts: 28
Joined: Sat Nov 22, 2003 11:47 am
Location: france

ftax is not a number

Postby paq1200 » Mon May 02, 2005 3:42 pm

I am having the same problem. It is the ftax is not a number. What do I need to check.


Thanks
Mike
paq1200
 
Posts: 15
Joined: Sun Jan 16, 2005 9:22 pm
Location: Texas

Previous

Return to Help: Cart / General

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron