1

We are using Drupal Commerce 7.x-1.4 and have a need to calculate the taxes on an order at checkout using an external service. When we make a call to this external service, it takes the Commerce order id as an argument, access the Drupal database, finds the components of the order with the passed id, checks each line item and returns a tax amount for the entire order based on its own set of rules. Since the tax tables and rules are shared by another system, it's best to tap this service to ensure consistency with other applications when doing calculations.

The problem is that I can see a hook specifically designed to bypass the Commerce tax Rules system (hook_commerce_tax_type_calculate_rates) and allow a user to do their own tax calculations, but that works per line item as the comment in the hook states:

An implementation might contact a web service and apply the tax to the unit price of the line item based on the returned data.

We are indeed contacting a web service, but not for each line item. Just for the final order as a whole. So, unfortunately, this is not the answer.

Is there a way to hook in and override the tax calculation on the entire order either by intercepting the call to calculate the tax and overriding the processing (without hacking the Commerce modules) or altering the calculated result and be able to show it on the Tax line in the order summary? Might there be a hook I'm overlooking or maybe someone has some other suggestion that I might explore?

Thanks.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.