How to set up tax rules for sales within Canada in Magento
by Monica Olinescu on August 17, 2009
Objective: Set up the taxation system for Magento for sales within different provinces of Canada.
Entering the Tax Rates for Retail Sales in Canada
The tax rates used in this example are listed below. DISCLAIMER: the rates and tax rules may not be correct or up to date and are listed here to demonstrate how different rates can be implemented in Magento. Do not use these rates without verifying with the proper authorities that they are correct.
| Location | Rate | Note |
|---|---|---|
| GST (Canada-wide) | 5% | Applied to products and shipping all over Canada. |
| HST (New Brunswick) | 13% | Includes GST |
| HST (Nova Scotia) | 13% | Includes GST |
| HST (Newfoundland) | 13% | Includes GST |
| PST (Ontario) | 8% | Added to GST |
| PST (British Columbia) | 7% | Added to GST |
| PST (Manitoba) | 7% | Added to GST |
| PST (Saskatchewan) | 5% | Added to GST |
| PST (Prince Edward Island) | 10% | Compounded with GST |
| TVQ (Quebec) | 7.5% | Compounded with GST |
* Tax rates for the territories are not included here, and to my knowledge Alberta does not have any retail sales tax.
The first step is to set up the tax rates within Magento.
Go to Sales > Tax > Manage Tax Zones & Rates. Click Add New Tax Rate and fill out the relevant information. Enter the name of the tax in the Tax Identifier. This name will appear on the customer’s invoice. Leave the Zip/Postal Code field with a “*”. For the rate field you can enter integers to represent the percentage of the tax. For example, entering 7 will set the rate to 7%.
After you entered all the rates for each province the Manage Tax Zones & Rates main screen should look like this.
Setting up the Tax Rules
Now that we have defined the tax rates for each province we need to give Magento some more information about how to use the rates:
• Taxes (as defined below) are applied to all products and shipping charges for all customers.
• GST is applied to all products sold to any province except NB, NS, and NF where HST is applied
• For Ontario, BC, Manitoba and Saskatchewan, apply GST to the amount before taxes and apply PST to the amount before taxes and add them up for the grand total.
• For PEI and Quebec apply the GST to the amount before taxes and then apply PST/TVQ to the (amount before taxes + GST)
To set up the tax rules open up Sales > Tax > Manage Tax Rules and click Add New Tax Rule. In the Tax Rate field you will see all the rates that were added in the previous step.
Setting up GST and HST
Let’s add the GST for all provinces and the HST for the relevant provinces for taxable goods and shipping (as far as I know shipping is provided as a service and can be marked up and is therefore taxable in Canada – don’t take my word for it).
Name: Retail Customer-Taxable Goods-Canada (can be anything you like)
Customer Tax class: Retail Customer
Product Tax class: Select both Taxable Goods and Shipping by pressing down Ctrl and clicking on the two items.
Tax Rate: Select GST and the HST tax rates (for NB, NS, NF)
Priority: Set this to 1. This field will be explained later.
Sort Order: Set to 1.
Save the tax rule and let’s see if this worked. Go to your store and add an item in the cart. When the shopping cart page is displayed you should see an Estimate Shipping and Tax box. Select Canada, Newfoundland and click Get a Quote.
You should now see a little + to the left of ‘Tax’ in the grand total box. Click that to open up the tax details.
Note: If you’re not seeing the tax details, it may be because the store is configured to hide the tax details. To fix that go to System > Configuration > Tax : Display and set Display Full Tax Summary to “Yes”.
If you select a province like Ontario or British Columbia you should see:

Subtotal with taxes
This is incorrect because for these provinces we need to apply the PST to the subtotal and add it with the GST to determine the ‘Grand Total’.
Adding non-compounded provincial sales taxes to the GST
As listed in the table at the beginning of the post, the PST for Ontario, British Columbia, Manitoba and Saskatchewan must be added to the GST, but unlike compounded taxes like the TVQ and the PST in Prince Edward Island, the PST must be applied to the original subtotal and then added to the GST.
To do that we need to add individual tax rules for the tax for each province as follows.
By setting the Priority field to 1 we are telling Magento to add the tax with other taxes with the same priority (like the GST tax defined with the rule Retail Customer-Taxable Goods-Canada).
Try out these new settings.
Adding compounded provincial sales taxes to GST
In PEI and Quebec the provincial tax is applied to the amount = subtotal + GST applied to the subtotal. To define this compounded tax rule we need to tinker with the Priority field and set this field to 2 (since our GST tax rule has priority 1).
The final tax rule table will look like this:
Troubleshooting
If the taxes changing as you select different provinces in the estimator you may want to check the ‘Tax Based On’ field in System > Configuration > Tax : Calculation . Make sure it is not set to ‘Shipping Origin’.
Reference: This post was created using in part information from a very helpful post on the Magento forum.




26 comments
Great tutorial, I’ve been looking for something like this for a while.
by KidA on August 18, 2009 at 12:36 pm. #
Great tutorial! Thank you so much, this saved me a lot of time.
by Jen on August 25, 2009 at 3:13 pm. #
I knew there was a reason I was procrastinating in setting up this store… it was so that you’d have time to write this post! Thanks!
by Derek Martin on October 4, 2009 at 1:34 pm. #
I’m glad it was helpful. Let me know if you are having any trouble setting it up.
by monica on October 6, 2009 at 1:52 pm. #
Very well explained.. BUT for some reason, when an Ontario order (for example) is placed.. the tax is totaled on the GST line and the PST line appears but with no value in the field. Do you know how to fix this? Law requies Ontario to separate out the GST adn PST on separate lines with separate values
by andrew on November 12, 2009 at 6:04 am. #
Hi Andrew,
Sorry about the late reply.
Good point! The problem starts in /app/design/frontend/default/default/template/checkout/total/tax.phtml
That’s where the tax details are being compiled (unless your current theme overwrites this file).
I will look into this and post an update.
Thanks for your comment!
by monica on November 24, 2009 at 9:24 pm. #
I also found this little tutorial very helpful. But of course, I too would like to get the GST and PSTs seperated.
Thanks alot! I will look into the template too.
by Eric on November 26, 2009 at 2:44 pm. #
Here’s my fix in template/checkout/total/tax.phtml
right after
1){
$rate['amount'] = ($rate['percent']/100) * $subtotal;
}else{
$rate['amount'] = $amount;
}
?>
And then, when it’s displayed later on:
<td rowspan="” class=”a-right” style=”getTotal()->getStyle() ?>”>
helper(‘checkout’)->formatPrice($rate['amount']); ?>
You can of course remove the commented out if and the rowspan altogether since we’re not using it anymore.
I’ve tried it on some different totals and it seems to work fine.
by Eric on November 26, 2009 at 4:20 pm. #
Sorry about the php tags messing stuf up here so, right after: foreach ($rates as $rate):
if(count($rates) > 1){
$rate['amount'] = ($rate['percent']/100) * $subtotal;
}else{
$rate['amount'] = $amount;
}
$rate['amount'] = $amount;
}
And then, remove the if ($isFirst): end it’s endif.
The rowspan is now useless.
And change the line that displays the amount to
$this->helper(‘checkout’)->formatPrice($rate['amount'])
by Eric on November 26, 2009 at 4:23 pm. #
Thanks Eric! In principle this should work, but there are three things that need to be addressed:
1. How do you get the subtotal? This something that really confuses me about Magento. I’m quite familiar with MVC, but I can’t for the life of me understand what controller this template belongs to.
2. This solution works fine with non-compounded tax rates, but it would be nice for it to handle compounded rates as well.
As a note: Calculating the tax amounts in the template violates MVC rules. Calculations need to be done in the model, or in the worst case in the controller. The model that performs the tax calculations for a given address is Mage_Sales_Model_Quote_Address_Total_Tax. It uses Mage_Tax_Model_Calculation. So ideally, the solution would happen in this model (I think).
Having said all this, thanks for your comment. This is a great quick fix for Ontarians. If you know how to get the $subtotal, please post a comment and I will update the post with your solution.
Thanks again,
Monica
by monica on November 28, 2009 at 2:51 pm. #
You can get the subtotal with:
$totals = Mage::getSingleton(‘checkout/cart’)->getQuote()->getTotals();
$subtotal = $totals["subtotal"]->getValue();
by Scott on January 1, 2010 at 2:15 pm. #
[...] has provided another well written article on setting up Magento to handle Canadian tax. You should also be sure check that the tax rates you use are up-to-date when setting up your [...]
by How to configure Magento for sales tax in Canada | Blue Lotus Creative on March 5, 2010 at 9:12 am. #
After having some trouble with this myself, I ended up writing a blog post to help others deal with this issue.
Let me know if this helps:
http://www.bluelotuscreative.com/blog/how-to-configure-magento-for-sales-tax-in-canada
by Gabriel McCay on April 15, 2010 at 8:32 pm. #
wow, thats random, someone posted a link to my blog post about this article. Well, anyways, hope this article helps. Its very detailed. Please comment if you find it useful.
by Gabriel McCay on April 15, 2010 at 8:35 pm. #
Thank you for your tutorial. Very helful. It works great for me with the compounded taxes but it only applies the GST for my HST provinces. My priorities looks to be setup ok…
Any idea why it’s doing that ?
by Alex on July 1, 2010 at 10:41 am. #
Hello again guys!
I just came back here because I was looking for something else and just noticed that I forgot to tell you how to get the subtotal. No, it is not the way Scott said it, you just need to put
$subtotal =($amount / $percent)*100;
right before my $rate['amount'] = ($rate['percent']/100) * $subtotal; statement. This will work fine with every type of taxes.
by Eric on July 13, 2010 at 9:43 am. #
Mine is doing the same as Alex. Why?
Alex | Jul 1st, 2010
Thank you for your tutorial. Very helful. It works great for me with the compounded taxes but it only applies the GST for my HST provinces. My priorities looks to be setup ok…
Any idea why it’s doing that ?
by Harry on July 22, 2010 at 9:24 pm. #
Hi,
Is it possible to show Tax details in a PDf invoice. We have a hard time showing the 5% GST and 7.5% PST.
This would help VERY VERY much.
Michael
by Michael on August 9, 2010 at 11:16 pm. #
Hey Michael,
You can check out this post to help you generate the pdf invoice.
http://www.magentocommerce.com/boards/viewthread/2588/
Raz
by Razvan on August 10, 2010 at 12:04 pm. #
Thank you for your grate instruction.
I have a question:
In BC there is a Levy / Environmental fee that should apply to some products. For example if you want to buy a ‘LCD Monitor’ there is an extra $11.00 environmental fee before tax. Or, $5.00 environmental fee for every ‘Tire’ for your car. How can I set up Magento to add these extra fees for only BC customer’s base on the special amounts of every required product?!!
(the environmental fee is different for every product, and some products doesn’t have it at all)
Thank you for your help in advance.
Alex
by Alex Tavanayan on October 14, 2010 at 8:11 pm. #
Hi Alex! It seems like it should be possible, but I haven’t been using magento in a long time. Check out the last paragraph of the “Tax Rate Support” section in this post: http://blueparabola.com/blog/magento-feature-analysis-series-part-12-international-support-offering
by Monica Olinescu on October 17, 2010 at 12:20 pm. #
You you should change the post name Sleekd » How to set up tax rules for sales within Canada in Magento to something more specific for your content you create. I loved the the writing nevertheless.
by Team Roster on October 30, 2010 at 2:25 am. #
Is it possible the option to show the tax details isn’t there in the free version of magento ? Because I don’t seem to see the option “configuration” in “System” menu.
As quoted from the article:
Note: If you’re not seeing the tax details, it may be because the store is configured to hide the tax details. To fix that go to System > Configuration > Tax : Display and set Display Full Tax Summary to “Yes”.
by Alex on November 2, 2010 at 12:05 am. #
Eureka! I’ve solved the Magento Canadian tax situation and it’s simpler than you think! You need a complete set of tax rates and rules. Read my article on how to do it:
http://innoveight.ca/stuff/blog/100-magento-canadian-taxes
by Trevor on December 15, 2010 at 9:40 pm. #
[...] A few blog posts show how to setup Magento with Canadian taxes: http://www.bluelotuscreative.com/blog/how-to-configure-magento-for-sales-tax-in-canada and also http://sleekd.com/general/how-to-set-up-tax-rules-for-sales-within-canada-in-magento/ [...]
by Magento Canadian Taxes Setup | InnoVeight.ca on January 27, 2011 at 12:30 pm. #
Hi Monica,
i want to set up a canadian store, but i want to make sure that the shop shows a grand total price and tax will be included in that price after checkout. I want to offer the same grand total price all over the country. Is that possible?
thanks in advance,
Jan
by Jan on December 21, 2011 at 6:17 am. #