silvershop-core icon indicating copy to clipboard operation
silvershop-core copied to clipboard

Only apply tax to some products

Open asecondwill opened this issue 8 years ago • 15 comments

Is it possible to only apply tax to some products in the catalog? Which modifier should i look at using for that?

GST in Australia does not apply to food items for eg.

asecondwill avatar May 15 '17 18:05 asecondwill

You can write your own Modifier for that. I guess you'd have to add some sort of Type field to a product to determine whether or not tax (or which rate) should be applied.

bummzack avatar May 15 '17 18:05 bummzack

oh. ok thanks.

asecondwill avatar May 15 '17 19:05 asecondwill

Hi @asecondwill

I have made a gist here doing somewhat like that: https://gist.github.com/hpeide/fee33737ad5efa5806396e5f6a91b87c

It do not work that well combined with the Discount module, so if you stumble on a good solution for that, please post! :-)

ghost avatar May 16 '17 10:05 ghost

hi @hpeide - thanks for this. very helpful.

I think the discount module issue is because you are going back to the product and calculating the price.

Maybe if we can somehow use the attribute on the product to influence the $incoming value directly just for tax it won't mess up anything else.

asecondwill avatar May 16 '17 13:05 asecondwill

I don't think you need to rely on the $incoming value. Just ignore it and calculate tax based on order contents (accessible via $this->Order())

bummzack avatar May 16 '17 13:05 bummzack

ok. does $this->Order() contain shipping and discount stuff, or just product line items?

asecondwill avatar May 16 '17 13:05 asecondwill

answer: no. so how to avoid losing the shipping and discount calculations. tricky.

asecondwill avatar May 16 '17 14:05 asecondwill

actually. we need to consider what the discount has been applied to.

asecondwill avatar May 16 '17 14:05 asecondwill

There is some abandonware that has some crossover.

https://github.com/burnbright/silverstripe-shop-taxframework

asecondwill avatar May 16 '17 15:05 asecondwill

@jedateach - do you have any advice on this topic?

asecondwill avatar May 16 '17 15:05 asecondwill

https://github.com/burnbright/silverstripe-shop-taxframework/pull/7

made an attempt at getting tax Framework to work in 3.5

asecondwill avatar May 16 '17 19:05 asecondwill

That module you linked to doesn't do things differently than I suggested. It doesn't take discounts into consideration either…

The architecture with Order-Modifiers only works well for certain scenarios. Ideally, an order-modifier is a self-contained entity that can perform its task without knowledge of other modifiers. As soon as you have modifiers that operate on the same items as others do, without knowledge of the changes made by another modifier, then you'll run into problems.

So the scenario where you have a tax per product-type combined with coupons can get problematic (because your tax doesn't operate on an incoming total, but calculates from base-prices instead).

If you have a good idea for a better architecture, I'm all ears. I think this should be some sort of RFC-style document/issue where the new architecture can be discussed.

bummzack avatar May 16 '17 19:05 bummzack

That module you linked to doesn't do things differently than I suggested. It doesn't take discounts into consideration either…

Yep. i realise that. good base though to build on.

As soon as you have modifiers that operate on the same items as others do, without knowledge of the changes made by another modifier, then you'll run into problems.

Agreed. That's discounts for you. i'm not even sure i can get my head round exactly what i'd want to happen. possibly it changes depending on the law / type of discount etc. it's probably epicly hard.

If you have a good idea for a better architecture, I'm all ears

i'm not that clever. I didn't mean to imply i thought it was all wrong. sorry if my ticket came off as rude.

asecondwill avatar May 16 '17 19:05 asecondwill

I'm reopening this, so that this discussion isn't getting lost and can be considered when there are architectural changes about to happen.

@asecondwill You might still be able to make it work by rolling your own Tax-Modifier. If you install the discounts-module, there are several ways to figure out the discounted amount (either per product, or total). You would then have to incorporate these amounts into your tax-calculation. I guess in the end it really depends on what kind of discounts you need.

bummzack avatar May 16 '17 19:05 bummzack

there are several ways to figure out the discounted amount (per product)

Any further hints there? this is the bit im struggling with.

Also, how can i get the shipping amount after discount?

asecondwill avatar May 25 '17 15:05 asecondwill