0
votes

This is a really odd problem. I am using Woocommerce, and have added an option for users to opt out/add shipping insurance on the checkout page. The checkbox is connected to an AJAX function that does what it is supposed to do. The fee gets added just fine. Every time the cart is changed in any way, the fee is removed, re-calculated, and added again to the cart. This part of the code is working fine.

The problem is that the actual total of the website isn't working. I am accessing the total using the following code:

WC()->cart->total

This calculates the rest of the fees just fine, but omits the fee representing the shipping insurance. I don't have any custom code that would specifically remove this fee from the calculation, so I am dumbfounded as to what might be causing this.

I hope to not have to post the entirety of my custom code here, so my question is what could possibly cause the total to ignore aprogramatically added fee?

1
Did you ever find a solution to this? I'm running into the same problem.miestasmia

1 Answers

0
votes

After you add your custom fields, there should be:

$order->calculate_totals();