Skip to content

Commit

Permalink
attempt to fix incorrect total calculation in some woocommerce setups
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Jan 15, 2025
1 parent d989425 commit 10d024a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion classes/WpMatomo/Ecommerce/Woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ public function on_cart_updated( $val = null, $is_coupon_update = false ) {

/** @var \WC_Cart $cart */
$cart = $woocommerce->cart;
if ( ! $is_coupon_update ) {
$cart->get_cart_contents(); // triggers loading cart info from session
if ( ! $is_coupon_update
|| (
! $cart->get_total( 'total' )
&& ! did_action( 'woocommerce_before_calculate_totals' )
)
) {
// can cause cart coupon not to be applied when WooCommerce Subscriptions is used.
$cart->calculate_totals();
}
Expand Down

0 comments on commit 10d024a

Please sign in to comment.