onAfterCartProductsLoaded

  • Posts: 16
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
4 months 4 weeks ago #361688

-- 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.

Last edit: 4 months 4 weeks ago by ShepherdsStream. Reason: needed to explain better.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 months 4 weeks ago #361689

Hi,

You sure can use onAfterFullCartLoad to calculate the taxes.
Make sure that you update $cart->full_total with the tax information and the price_value_with_tax

The following user(s) said Thank You: ShepherdsStream

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
4 months 3 weeks ago #361714

that worked great

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum