Rethinking easy Tarrif fix

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Rethinking easy Tarrif fix

Post by Portman »

OK,

So I started with an easy flat tarrif module that just added 10% to the order at checkout - it worked fine.... but as I go down the US tariff rabbit hole I am finding it is not as straight forward as all this - there are variable tariff rates per product...

What I thought I would do is jerry rig the tax feature of the site for US customers (tax is only being used for domestic customers - I don't need to charge taxes on any international orders) ....

Step 1... Create a US tariff rate field per product in the database - EASY

Step 2 would be to create a function that would detect if the customer is US based (they have to be logged in on my site to order so that is easy) and then I assume I need to add the tarif rate to products_tax in orders_products field in the database.

My first question is where is this currently being done for regular taxes? - I just cant quite figure this out, once I know this I can probible create something to apply the tariff rates here

Step 3 I assume I replicate the ot_tax module to look for stuff in the products_tax field if the customer is US and the rest should take care of itself....

My second question is - is my logic correct or am I missing something?


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Rethinking easy Tarrif fix

Post by ecartz »

If you need different products to be charged a different rate, you can make more tax classes.

You can only apply one tax class to a product, so if you need the tax rates to vary separately, you need multiple tax classes. E.g. if you have three products: one, two, and three. One and Two have the same tax rate in Australia, but Three is different. In the US, Two and Three have the same rate but One is different. You would need three tax classes, one for each product. And you'll need to set two tax rates for each tax class. Six total.

Now, if you add Four, which has the same rates as One, you can just give Four the same tax class as One.
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Rethinking easy Tarrif fix

Post by Portman »

Hello @ecartz,

Thanks for your reply, I appreciate it, but I am totally confused by what you mean...

In My Situation ALL products in Australia have to have a GST rate of 10% added.

For my US customers some products will have tariffs of 0.00%, 10.00%, 12.5%, 15% and maybe even more (I have not worked them all out yet)

If I have the tax class on all products at GST (10%) how do I then add the various different tariff rates to the same products but keep the GST rates there for my Aussie customers?

If the US tariff rates were all the same I could see this working - ie set a tax rate of 10% to all US zones - but if I have multiple US tax(tariff) rates how do I make this work?
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Rethinking easy Tarrif fix

Post by burt »

1. Have a new `tab` in the admin/catalog.php page allowing you to set up a Tariff rate per country on each product.

This data saves to a new table.
Product ID, Country ID, Rate

EG:
1, US, 0.10
2, US, 0.20

Other countries might do tariffs in the future, so might as well get ready for them now, as it's not much extra code.

You coudl just hardcode this into the table (eg using PHPMyAdmin) rather than have an admin `tab` UI.

2. Have a new order_total module which determines the `to` country, looks up the correct rate per product ordered, totalises the amount and adds it onto the order.

All of which is, more or less, what you explained to yourself :+1:
I am not here to build for you.
I am here to build with you. Let's help each other.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Rethinking easy Tarrif fix

Post by ecartz »

Portman wrote: Wed Aug 27, 2025 7:17 am If I have the tax class on all products at GST (10%) how do I then add the various different tariff rates to the same products but keep the GST rates there for my Aussie customers?
You add new tax classes for the products that get different tariff rates to the US. For each one, you set a GST rate of 10% in Australia (you can do this before you assign any products to the tax class).

You'll end up with one tax class for each US rate (including zero). Since you only have one tax rate for Australia, you won't need any more tax classes for that.

Tax rates are per class and per zone. You'll have two tax zones, Australia and US. You'll have two rates for each tax class: 10% in Australia and whatever in US (except zero for the US won't need its own rate; just the Australia rate for that class).

It makes things more complicated in Australia, because you now have multiple tax classes each with the same tax rate value. This will be duplicative, but I would still argue easier than creating some special new tax handling just for tariffs.

Whatever will have the most common US tariff rate should get your existing tax class. Just add the US rate to it for the US zone (unless it's zero, but I'm guessing 10% will be more common).
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Rethinking easy Tarrif fix

Post by Portman »

Thanks @burt... this is kind of what I was thinking of doing originally, i was just going to have the us tariff code for each item as part of the products table (products_us_tarrif) rather than a seperate table like you are suggesting.

I guess rather than use the products_tax field in the actual orders_products table - I could just work out the tariffs per item at checkout using that but I feel like I would be totally out of my deapth to create this from scratch - is there an exisitng page that I could use as a template to create this?

@ecartz ... I know I am being thick here but I still cannot see how I can set multiple tax classes (and different tax rates per class) to a product - I know I can set up the 2 different classes and then have 3 or 4 different rates per class (specifically for us tariffs) - but I cannot see how to apply them - to each product. from what I can see there is only 1 tax class field per product and you cannot set specific rates per product.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Rethinking easy Tariff fix

Post by ecartz »

There is only one tax class per product. Different products can have different tax classes.

There is one tax rate per zone and class.

Set a tax class. Assign two tax rates to it. One for the US tax zone and one for the Australia tax zone.

You currently effectively have two zones for each product: Australia and not-Australia. Not-Australia is implicit. You want to have three:

1. Australia. Rate always 10%.
2. US. Varying rates.
3. Neither Australia nor US. Rate always 0%.

The third can stay implicit.

Create tax classes for each US rate you need to support. For each tax class, create an Australia rate of 10%. Create a US rate of whatever. Assign the tax class (as the only tax class) to products that get that US rate.

I'm not following why you think you need to assign multiple tax classes per product. Each product has one tax class. Each tax class (except one, where the US rate is 0%) has two tax rates, one for Australia and one for US. Every tax rate has one tax class and one tax zone.

Each tax class will have an Australia 10% rate. This is duplicative but necessary.

Every tax class except the one for US 0% will have a US tax rate.

Every product will have exactly one tax class. This will become much easier to understand when you realize that you don't need products to have more than one tax class. You just need tax classes to have more than one rate.
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Rethinking easy Tarrif fix

Post by Portman »

Thanks @ecartz ... I think I get it now....

So if I have 3 different 'tax' rates for US Tarrifs... say 0%, 10%,and 15% ...

I set up 3 Differnt Tax Classes...

Class 1 - AU rate 10% - US Rate 0% (or nothing for this one)

Class 2 - AU Rate 10% - US Rate 10%

Class 3 - AU Rate 10% - US Rate 15%

then set the class per product in such a way that the class reflects the US tarrif amount as the AU rate will always be 10%....

I knew I was being slow.... thanks for your patience :?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Rethinking easy Tarrif fix

Post by ecartz »

Yes, like that.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply