Home Woocommerce won't add my custom fee to the cart total
Reply: 1

Woocommerce won't add my custom fee to the cart total

user3628576
1#
user3628576 Published in 2015-11-21 13:45:40Z

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?

Otvazhnii
2#
Otvazhnii Reply to 2016-04-07 16:25:12Z

After you add your custom fields, there should be:

$order->calculate_totals();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307165 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO