Skip to content
Advertisement

woocommerce_cart_calculate_fees load after woocommerce_before_cart_table

I have a problem trying to do some calculations with woocommerce_before_cart_table custom values and passing them to woocommerce_cart_calculate_fees. The problem is that woocommerce_before_cart_table is loading first and I am not able to pass that values from woocommerce_before_cart_table to woocommerce_cart_calculate_fees hook…

JavaScript

How can I pass that calculation on woocommerce_cart_calculate_fees hook?

Thanks

Advertisement

Answer

So If I understand you are making some test of calculations related to booking data in your first function hooked in woocommerce_before_cart_table. I have made a little change in your code for global $wpdb;:

JavaScript

Once you are sure of your calculations, as cart data is kind of live, you can use your calculation code directly in your 2nd hooked function in woocommerce_cart_calculate_fees action hook, with some little changes as this hook has a native $cart_object argument.

So your code should be something like this:

JavaScript

Code goes in functions.php file of your active child theme (or theme) or also in any plugin file.

This code is untested, but it should work…

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement