- Posts: 23
- Thank you received: 2
onAfterCartProductsLoaded
- ShepherdsStream
-
Topic Author
- Offline
Less
More
2 years 4 months ago - 2 years 4 months ago #361688
by ShepherdsStream
onAfterCartProductsLoaded was created by ShepherdsStream
-- 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.
-- 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: 2 years 4 months ago by ShepherdsStream. Reason: needed to explain better.
Please Log in or Create an account to join the conversation.
2 years 4 months ago #361689
by nicolas
Replied by nicolas on topic onAfterCartProductsLoaded
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
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.
- ShepherdsStream
-
Topic Author
- Offline
Less
More
- Posts: 23
- Thank you received: 2
2 years 4 months ago #361714
by ShepherdsStream
Replied by ShepherdsStream on topic onAfterCartProductsLoaded
that worked great
Please Log in or Create an account to join the conversation.
Time to create page: 0.044 seconds