close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Error in eCart code

Thread began 11/08/2009 10:55 am by markdoyle87077 | Last modified 11/10/2009 11:48 am by markdoyle87077 | 3590 views | 9 replies |

markdoyle87077

Error in eCart code

Hi,

I have a rule as follows and it works fine, it is designed to calculate the tax at 19%:

<%
function WAEC_dmbp_SalesTax()
totalCharge = 0
if (true AND ((UBound(dmbp.Items) > 0) AND (( cStr(Session("TaxRate"))<>"" )))) then
totalCharge = totalCharge + ((WA_eCart_TotalColumn(dmbp, "TotalPrice") - (dmbp_GetDiscounts()) * 1) * (0.19))'Result
end if
WAEC_dmbp_SalesTax = WA_eCart_FormatNumber(totalCharge, dmbp.ForceDecimalsC, dmbp.DecimalPlacesC)
end function
%>

I have modified it as I want to get the tax from a database, I have set a session variable TaxRate to hold the data and I have modified the rule to:

<%
function WAEC_dmbp_SalesTax()
totalCharge = 0
if (true AND ((UBound(dmbp.Items) > 0) AND (( cStr(Session("TaxRate"))<>"" )))) then
totalCharge = totalCharge + ((WA_eCart_TotalColumn(dmbp, "TotalPrice") - (dmbp_GetDiscounts()) * 1) * Session("TaxRate"))'Result
end if
WAEC_dmbp_SalesTax = WA_eCart_FormatNumber(totalCharge, dmbp.ForceDecimalsC, dmbp.DecimalPlacesC)
end function
%>

The cart works fine on my ordersummary.asp page with this rule, however on my confirmdetails.asp page it throws the following error:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "Germany"]'
/dmbc/WA_eCart/dmbp_VB.asp, line 260

I have checked the line entry and it points to the modified rule above, I know what the problem is but I do not know how to resolve it. The session TaxRate is showing as 0.19 on the ordersummary.asp page but when we go to the confirmdetails.asp page the session TaxRate is set to Germany although I have not changed the value of the session in my code.

I have attached the files, hope this helps. Cannot provide a working link as this would bring my site down.

Regards

Mark Doyle

Attached Files
eCart.zip
Sign in to reply to this post

markdoyle87077

Error in eCart Code

Please ignore where I said confirmdetails.asp I meant paymentdetails.asp, file is attached. The confirmdetails.asp file is the file that posts to the ordersummary.asp page.

Regards

Attached Files
paymentdetails.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Your TaxRate session variable is being set to the billing country from the form:
<%
if (cStr(cStr(Request.Form("billingcountry"))) <> "") then
Session("TaxRate") = "" & cStr(cStr(Request.Form("billingcountry"))) & ""
end if
%>



In the case of your error, it is getting set to "Germany", you cannot use a string in mathematical operation.

Sign in to reply to this post

markdoyle87077

Error in eCart

The code

<%
if (cStr(cStr(Request.Form("billingcountry"))) <> "") then
Session("TaxRate") = "" & cStr(cStr(Request.Form("billingcountry"))) & ""
end if
%>

sets Session("TaxRate") to a string from the database, it is either 0.19 or 0, I have verified it doing this on ordersummary.asp page where tax and shipping is calculated so i know the Session is working correctly at that point. When i then click to go from the ordersummary.asp page to the paymentdetails.asp thats when the error is shown even though i never change the value of the Session:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "Germany"]'
/dmbc/WA_eCart/dmbp_VB.asp, line 260

I can supply more files if you need them.

Regards

Sign in to reply to this post

Jason ByrnesWebAssist

That code uses the Request.Form collection, not a recordset value.



This code:
<%
if (cStr(cStr(Request.Form("billingcountry"))) <> "") then
Session("TaxRate") = "" & cStr(cStr(Request.Form("billingcountry"))) & ""
end if
%>


Does not use a recordset value, it uses a form value. If it used a recordset value, it would look like:
<%
if (cStr(cStr(recordsetname.Fields.Item("TaxValue").Value)))) <> "") then
Session("TaxRate") = "" & cStr(cStr(recordsetname.Fields.Item("TaxValue").Value)) & ""
end if
%>





notice the difference in the lines setting the session value:
Session("TaxRate") = "" & cStr(cStr(Request.Form("billingcountry"))) & ""
Session("TaxRate") = "" & cStr(cStr(recordsetname.Fields.Item("TaxValue").Value)) & ""



Yours uses the Request.Form collection. The other uses the recordsetname.Fields.Item collection.

Sign in to reply to this post

markdoyle87077

Error in eCart

Jason,

Think you have misunderstood me here so I will take it page by page. On the confirmdetails.asp page the form field 'billingcountry' is populated from a recordset rsShipState. The recordeset gets the following values from the database:

ID english german salestax
1 Germany Deutschland 0.19
2 United Kingdom Großbritannien 0.19
3 France Frankreich 0.19
4 Holland Niederlande 0.19
5 Italy Italien 0.19
6 Greece Griechenland 0.19
7 Denmark Dänemark 0.19
8 Lichtenstein Lichtenstein 0.19
9 Austria Österreich 0.19
10 Belgium Belgien 0.19
11 Ireland Irland 0.19
12 Switzerland Schweiz 0
13 Romania Ungarn 0.19
14 Hungary Rumanien 0.19
15 Finland Finnland 0.19
16 Luxembourg Luxemburg 0.19
17 Macedonia Mazedonien 0.19
18 Spain Spanien 0.19
19 Poland Polen 0.19
NULL NULL NULL NULL

When this information is posted to the ordersummary.asp page the form field 'billingcountry' holds a value from the 'salestax' column in the database, it does not hold an english or german value as this value is obtained using javascript and is set to the hidden form field 'billingcountryhidden'

When the information arrives at the ordersummary page the following code is executed:

<%
if (cStr(cStr(Request.Form("billingcountry"))) <> "") then
Session("TaxRate") = "" & cStr(cStr(Request.Form("billingcountry"))) & ""
end if
%>

The cart displays fine at this point and all the calculations are correct so i know that the 'salestax' column from the database is being set correctly so the SalesTax rule is being executed as it should, I have even debugged a little and got it to show me the value of the Session("TaxRate") on the ordersummary.asp page and it is holding the correct value.

When I then click 'Next' on the ordersummary.asp page to be taken to the paymentdetails.page thats when the error occurs:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "Germany"]'
/dmbc/WA_eCart/dmbp_VB.asp, line 260

I know its hard to believe but this is happening even though the code we are looking at suggests otherwise. I mean, why is it that the /dmbc/WA_eCart/dmbp_VB.asp file functions correctly on the ordersummary.asp page where the calculations are performed perfectly but cannot perform correctly on the paymentdetails.asp page.

There has got to be something we are missing and thats why i presumed it may be the code in eCart.

Sign in to reply to this post

Jason ByrnesWebAssist

The error message clearly states that the string "germany" is being used in the calculation.

Perhaps you could provide a link where I could see this in a browser to get a better feel of what is going on in the code.


Also try disabling the rule for the moment so we can troubleshoot what the session variable is really set to.

After disabling the rule, add the following after the body tag on the paymentdetails page add the following code to write to the screen the value of the session variable:
Session TaxRate = <%=Session("TaxRate")%>

Sign in to reply to this post

Jason ByrnesWebAssist

OK, wait, I see the problem now.


Line 377 of the ordersummary.asp page, you are setting the billingcountry form field to hold the country name that is stored in the billingcountryhidden form element:

<input name="billingcountry" type="hidden" id="billingcountry" value="<%=cStr(Request.Form("billingcountryhidden"))%>">



change that to:

<input name="billingcountry" type="hidden" id="billingcountry" value="<%=cStr(Request.Form("billingcountry"))%>">

so that it maintains the taxrate value

Sign in to reply to this post

markdoyle87077

Error in eCart

Hi Jason,

I have disabled all of the rules and added the Session TaxRate = <%=Session("TaxRate")%> to the ordersummary.asp page and the paymentdetails.asp page. When I run the site it shows the Session to be set at 0.19 in ordersummary.asp and United Kingdom on the paymentdetails.asp page. This is bizarre, you can download a video and see exactly what i mean; it has to be something in the code but i cannot figure it out. The video is available at error.zip

Regards.

Sign in to reply to this post

markdoyle87077

Error in eCart

Hi Jason,

That worked a treat, thank you very much.

Mark

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...