Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

CalculateSalesTax in DefaultTaxCalculator not being called when I change the OrderAddress



We're completing our migration to Commerce 12.5 so we now use our overriden version of DefaultTaxCalculator to calculate our taxes(CalculateSalesTax and CalculateShippingTax).

My problem is that we have a cart summary page where we let the client change the state so they can see the taxes they're gonna pay and to do so, we create an temporary address with that state and that gave us our taxes when the CartPrepare workflow was completed.

But now it doesn't and when I dug in the code to see what was going on, I've founded out that the CalculateSalesTax was not called when the CartPrepare was called but the CalculateShippingTax was.

Here's what we do we the user change the state in our cart page:

  • We add a new OrderAdress with the new state code (We set it in the state, regionname and regioncode fields) and the country code
  • We remove the old OrderAddress
  • We update each lineitems.ShippingAddressId
  • We run CartHelper.RunWorkflow(OrderGroupWorkflowManager.CartPrepareWorkflowName);

Why CalculateSalesTax is not called when I change my OrderAddress and is there a way to make it work?

When I change the quantity, both CalculateSalesTax and CalculateShippingTax get called like I anticipated.

Aug 09, 2018 21:29

This is a known issue and we are working on it. 

Aug 09, 2018 22:13

Is it fixed? If not, are there any workarounds?

Sep 04, 2018 15:06

Yes, it is now fixed in Commerce 12.8.0

The obvious workaround is to not change your OrderAddress, but to create a new one and assigne it to IShipment.ShippingAddress 

Sep 04, 2018 15:08

Commerce 12.8.0 is now available:

Sep 04, 2018 18:17

I've updated Commerce to 12.8.0 and I still have the same problem.

When I update my OrderAddress and call the CartPrepare workflow, CalculateSalesTax is not called, only CalculateShippingTax is called.

Sep 04, 2018 18:51

Hmm, it seems that I was mistaken. The bug you are seeing is something else, not the bug we were working on. I will check and get back to you

Sep 04, 2018 19:23

I filed COM-7854, we will be working on it soon 

Sep 05, 2018 8:45

Thanks for the feedback.

Am I supposed to see the detail of this bug in the bug list (

I don't see it when I search for it.

Also is the workaround supposed to work (even if the bug is not the same)?

I've tried to add a new address in CartHelper.Cart.OrderAddresses and remove the old one. I also updated the CartHelper.LineItems to set the new shippingAddressId but the CalculateSalesTax is still not called.

Sep 05, 2018 21:28

The bug is not yet made public.

Hmm, now I look more into it, it looks like the only working workaround is to change the lineitem quantity and then set it back. That would trigger the clearing of "cached calculation value".

And - I know you have reasons, but - why are you still using CartHelper, you should have been using new abstraction APIs already ;)  

Sep 06, 2018 7:50

I know about CartHelper, it's in our pipeline but we would need to change a lot of code to make it happen and we know we'll have to change a good part of it in the next year so we want to wait then to avoid changing it 2 times.

Sep 06, 2018 14:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.