lunar icon indicating copy to clipboard operation
lunar copied to clipboard

TaxDriver and Shipping Prices

Open ryanmitchell opened this issue 2 years ago • 3 comments

Discussed in https://github.com/getcandy/getcandy/discussions/234

Originally posted by ryanmitchell March 22, 2022 I have a custom tax driver (to interact with Avatax) and am trying to work out how to apply the tax returned to the shipping price (which itself comes from a 3rd party ShipEngine).

So my tax driver returns a getBreakdown() for each of the line items - perfect - all working well. I simply match the line id to the one I passed to Avatax and thats my tax value.

But I've no way of either adding an ad-hoc breakdown for shipping, or for applying a breakdown to the shipping option selected. Instead I have to pass a \GetCandy\Models\TaxClass, which is database driven, and therefore wouldnt scale (I would have to create a new model for every tax value Avatax returns for shipping).

I think this could be resolved by applying the tax driver to the GetCandy\DataTypes\ShippingOption, rather than passing a taxClass? But this would mean modifying the tax driver methods, as it expects a purchasable.

ryanmitchell avatar Aug 10 '22 12:08 ryanmitchell

Is this something you'd consider attempting a PR for @ryanmitchell ?

glennjacobs avatar Aug 10 '22 12:08 glennjacobs

Yeah I’ll take a look at it and see how I get on

ryanmitchell avatar Aug 10 '22 13:08 ryanmitchell

Ive actually taken a second look at it and I think I can work with things as they stand.

In my TaxDriver getBreakdown I can check for whether the purchasable is an instanceof \GetCandy\DataTypes\ShippingOption and if so apply some logic to add tax for shipping.

ryanmitchell avatar Aug 11 '22 06:08 ryanmitchell

@ryanmitchell should we close this issue now?

glennjacobs avatar Sep 29 '22 09:09 glennjacobs

Yep!

ryanmitchell avatar Sep 29 '22 09:09 ryanmitchell