Force Recalculate Cart Totals
Force recalculation of cart totals after updates.
// Force Recalculate Cart Totals
if (!function_exists('woo_discount_rules_force_recalculate_cart_totals')) {
add_action('woocommerce_before_cart', 'woo_discount_rules_force_recalculate_cart_totals'); // before cart page
add_action('woocommerce_before_cart_totals', 'woo_discount_rules_force_recalculate_cart_totals'); // before cart totals
add_action('woocommerce_before_checkout_form', 'woo_discount_rules_force_recalculate_cart_totals'); // before checkout page
add_action('woocommerce_checkout_update_order_review', 'woo_discount_rules_force_recalculate_cart_totals'); // during order review
function woo_discount_rules_force_recalculate_cart_totals() {
if (function_exists('WC')) {
if (isset(WC()->cart) && WC()->cart != null) {
if (method_exists(WC()->cart, 'calculate_totals')) {
WC()->cart->calculate_totals();
}
}
}
}
}