close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple tax rules for Canada

Thread began 5/12/2010 4:57 pm by nathan405389 | Last modified 5/13/2010 7:27 pm by Eric Mittman | 946 views | 1 replies |

nathan405389

Multiple tax rules for Canada

Hi there,
I am looking for some help in setting up mutiple tax rules for a Canadian based store. The province of the business charges a different rate to residing customers than if they were out of province. Any advice on making this work would be appreciated.

Sign in to reply to this post

Eric Mittman

What is the province that the merchant is in and what provinces do they want to charge tax for? This is the first step, you must have clearly defined criteria to setup the tax rules.

Once you know exactly under what circumstances and the value to charge then setting up the tax rules will be very easy.

The general idea is that on the page that your checkout page posts to (usually the confirm page) you will want to add a 'set session value' server behavior. This server behavior will be used to create a new session variable, you can call it province. In this variable you will store the value from the posted province select list on the checkout form.

Once you have the province held in a session variable you can create the charge rules based on your criteria. You would first want to check for the session variable existing, then based on its value. You would have a rule like this for each province that you wanted a different tax rate applied to. For the amount you would base it off of the cart subtotal and multiply it by the decimal tax rate, so for 8.5% it would be multiplied by 0.85. Please post back with any additional questions that you have about this.

Sign in to reply to this post

Maggie Simpson

Setting Session Variable

I have created my cart with the tax rule specifically for the state in which our business is located, where if ship to address is located within our state, then state sales tax is charged. This tax rule functions perfectly.
We also have nexus in three other states based on our delivery routes. Can I add the tax rules for these states in eCart1_PHP.php based on if and else if statements? Has the session variable in confirm.php (discussed above) already been created due to my original state tax rule? Sorry, I think I am just needing a little more clarity as to variable tax rules... thank you

Sign in to reply to this post

Jason ByrnesWebAssist

the shipping state is stored in the eCartCheckoutForm_shipping_state_province session variable.


you can set up different tax rules for each shipping state. in the trigger section use the Session Variable exists and Based on session variable value to set up the conditions to trigger that tax rate.

so you would set one rule for one shipping state

another for a different shipping state and so on.

the triggers will apply the rule only if the conditions are met causing an If else scenario.

Sign in to reply to this post

Maggie Simpson

Worked perfectly to set the tax rules based on session variable exists and is equal to state value. Thank you! Now I have to define further based on city and/or county. I am assuming ecart does not limit the number of tax rules that can be created?

Sign in to reply to this post

Jason ByrnesWebAssist

nope you can create as many rules you need.

Sign in to reply to this post

Maggie Simpson

Jason, you have been so helpful, thank you. A couple more questions regarding details for coding the tax rules...
I have coded different tax rules based on cities within certain states. Am I correct in my coding per the following example?

//eCart Rule
function WAEC_eCart1_Nebraska7SalesTax() {
$totalTax = 0;
if (true && ((isset($_SESSION['eCartCheckoutForm_shipping_state_province'])) && ((isset($_SESSION['eCartCheckoutForm_shipping_state_province'])?$_SESSION['eCartCheckoutForm_shipping_state_province']:"") == "NE") && ((isset($_SESSION['eCartCheckoutForm_shipping_city'])?$_SESSION['eCartCheckoutForm_shipping_city']:"") == "Ainsworth") || ((isset($_SESSION['eCartCheckoutForm_shipping_city'])?$_SESSION['eCartCheckoutForm_shipping_city']:"") == "Albion") || ((isset($_SESSION['eCartCheckoutForm_shipping_city'])?$_SESSION['eCartCheckoutForm_shipping_city']:"") == "Alliance") ||



and so on...
for all the cities within Nebraska that have a 7% tax rate? I am thinking that I set up the criteria correctly so that it identifies if the shipping_state_province variable is equal to "NE" AND the shipping_city variable is equal to one of many values (a OR b OR c), then assess this tax rate...
Also, how picky is the rule based on how people fill out the form with capitalization for their shipping cities? If someone fails to capitalize their city, will it not meet the rule and therefore not have tax assessed on the purchase? Thanks. Sorry to be such a headache.

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, that is correct, that rule looks like it should work


the tax rule is case sensitive.

you could edit the code to set the session variable on the confirm page:

php:
<?php


if (!session_id()) session_start();
if(
$_SERVER["REQUEST_METHOD"] == "POST")     {
  
$_SESSION["eCartCheckoutForm_shipping_city"] = "".((isset($_POST["shipping_city"]))?$_POST["shipping_city"]:"")  ."";
}
?>



to convert the string to lower case:

php:
<?php


if (!session_id()) session_start();
if(
$_SERVER["REQUEST_METHOD"] == "POST")     {
  
$_SESSION["eCartCheckoutForm_shipping_city"] = "".((isset($_POST["shipping_city"]))?strtolower($_POST["shipping_city"]):"")  ."";
}
?>




and use lower case in the tax rules to work around it.

Sign in to reply to this post

Maggie Simpson

Do I also need to establish that the eCartCheckoutForm_shipping_city session variable exists before going on to identify all of the OR conditions for each city using that tax percentage?

Sign in to reply to this post

Jason ByrnesWebAssist

yes, your first 2 conditions should be session exists to check that the city and state sessions are set before checking their value.

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