-- HikaShop version -- : 5.1.0
-- Joomla version -- : 4.4.5
-- PHP version -- : 8.1
-- Browser(s) name and version -- : Microsoft Edge Version 126.0.2592.68 (Official build) (64-bit)
-- Error-message(debug-mod must be tuned on) -- : no error message
We have built a plugin that will calculate the tax. We refuse to use Avalara or TaxCloud. The plugin is working only it is not including the shipping cost. Here is the request from my dev. Tax calculate: I could not find an event that I need. As your request, the Sales Tax will be calculated with a formula:
Subtotal + Shipping Fee = Total
Total * CombinedRate (%) = Sales Tax
In the plugin, if I hook on an event onAfterCartProductsLoaded
onAfterCartProductsLoad(&$cart)
I can update cart price with tax, but in this event, the $cart params does not include shipping price, so the Tax can be only calculated based on subtotal (without shipping fee).
I tried to hook on other events that are: onAfterCartShippingLoad or onAfterFullCartLoad
I checked in the source code of Hikashop, these events will be called after the event onAfterCartProductsLoaded, and the shipping information added to the $cart params in these events.
So, for these events, it can get Sub total + Shipping fee, and I can calculate tax correctly and update new price with tax to the $cart (include tax of shipping fee).
But on the cart form (checkout page), it will display price without tax (although $cart is updated correctly).
So I reverted to using the event onAfterCartProductsLoaded.
I would like to include the shipping in the sales tax calculation.
Please advise. Thank you.