close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

table for tax rates

Thread began 11/23/2009 9:22 am by watercolor346374 | Last modified 12/17/2009 3:56 pm by Eric Mittman | 2782 views | 21 replies |

watercolor346374

table for tax rates

Hi,
I was wondering if I could make a table with all of the ny county tax rates and could I use it instead of making rules for each county. If so, how would I use it to total the correct tax rate for items sold in ny. Also could you tell me how to store the tax rate in the table. I am having trouble with it. I built a back office page to fill in my county table which includes, countyid, name, tax. I am not sure how to store the tax rate.
Thank you

Sign in to reply to this post

Eric Mittman

Making the tax rules based on the dynamic data directly is not possible within eCart. There are other ways you can do this though. If you have session variables that you set based on the selection of the user you can use these session variables in the rules.

The idea is that you have the user select the county then you would use this value to filter a recordset. The values that you get in the rs would then be stored in session variables. You would then use these session variables as the trigger and amount of the tax for the selected county.

To start with on this you will need to ensure that you are storing the tax rate in the db along with the county. You should store this tax rate as a decimal value, so it will be like 0.05 for 5%.

This is the general high level overview, if you would like to go this route let me know what questions you have about any part of this and I will be glad to help you with what I can.

Sign in to reply to this post

watercolor346374

yes I would like to use my table for taxes

Hi Eric,
thank you for your reply. My table, counties, set up is:
countyid, key and auto increment
name, this is the name of the county
tax, the tax is in the table as a decimal
My understanding is that I would have a record set called rsTaxes and choose all in the table and filter by countyid. This record set would be on the checkout page.
Then you are saying that I would set up a session variable called tax (will have to review how to do this)
not sure how I would use it as a trigger.
Thank you

Sign in to reply to this post

Eric Mittman

You are exactly rite about the recordset, but you would want to make sure it is on the page that your checkout form posts to, so check the action on the form for that.

Once the recordset is in place you will then be able to create a new session variable, you can do this by going to Server Behaviors > eCart > General > set session value. For the trigger you can use the posted element for the county. For the value of this session variable you will set use the lightning bolt icon to expand the bindings for your newly created recordset. In here you will select the column that holds the tax rate.

That should ensure that you are setting the session variable accordingly. You can then use this session variable as a trigger for the charge rule. In the rule you will first create the trigger, for the condition in the trigger you would select 'session variable exists' then select this session variable. Then for the amount you would use based on cart subtotal and use the subtotal times your session variable name for the total amount of the charge. For this part you must enter the name of the session variable just as it was set like this:

php:
$_SESSION['<your var>']



If you set it up like this it should dynamically apply the county tax charge based on the selection of the user. If you have any trouble with this or need some more info let us know and we will be glad to help with whatever we can.

Sign in to reply to this post

watercolor346374

more on taxes and session

Hi,
I followed the instructions and when I test the page, I get this message:

Notice: Undefined variable: row_rsCounties in /Applications/MAMP/htdocs/megan_isaacs_cms/confirm.php on line 15
I have enclosed my confirm.php where the taxes will be posted. Also a screen shot of my tax rule. In NY the whole cart, items and shipping are taxed. I did check tax shipping in the cart. Also wondering how I can get the county name to show up on the form in the billing area, instead of the countyid.
Thank you

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

Eric Mittman

You are getting this error because the variable you are referencing in your set session value is from the recordset and this code occurs before the recordset is created. To resolve this problem you will need to move the code at line 15 to be just after what is currently on line 80. It would be best to have it in it's own code block below this.

Move this after line 80:

php:
<?php

if (!session_id()) session_start();
if(
$_SERVER["REQUEST_METHOD"] == "POST")     {
  
$_SESSION["eCartCheckoutForm_counties"] = "".$row_rsCounties['tax']  ."";
}
?>
Sign in to reply to this post

watercolor346374

It stopped the message, but no tax is showing or being calculted

Hi Eric,
Thank you for your help. The message is gone and the confirm form shows up. The tax row does not show up and when I run it no tax posts to the table. I must be missing something.
Thank you
Here is my corrected form with the tax rule in the tax area

Attached Files
taxes 2.zip
Sign in to reply to this post

Eric Mittman

The tax rule will only trigger if the conditions in the rule are met first. Since the conditions are just looking for a particular session variable to be set and the value is not being set this tells me that your recordset is not working properly. When I check on your page it looks like you are filtering the recordset on this value:

php:
$_GET['countyid']



If the county select list is named countyid then you should update this to be the posted version of this form element like this:

php:
$_POST['countyid']



If your county select list has a different name then you will need to update this to reflect the name of your list.

Sign in to reply to this post

watercolor346374

still not working

Hi Eric,
I changed the get to post on line 63. I reviewed my session variable for county taxes. As well as my tax rules. I do have in shipping the box checked for including shipping in cart total for taxes. Anyway still cannot get the tax to show on my confirm page. I did include confirm.php and screen shoot of my tax set up.
Thank you,

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

Eric Mittman

I think that the problem is still that you are not using the correct value in the filtering. Rite now on the confirm page you have this code:

line 61

php:
$colname_rsCounties = "-1";

if (isset($_GET['countyid'])) {
  $colname_rsCounties = $_POST['countyid'];
}



You are still referencing the get version of this value so your SQL variable is not being set correctly and not setting the session variable accordingly. With a tax rule like you have so long as the session variable has a value it will trigger the rule.

You should also make sure to add a new hidden form element to the form on this page. In the new hidden form element you will set the name to countyid and for the value use the session variable. This will ensure that when you submit the order after confirming it you will still have a working charge.

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...