diff --git a/includes/class-wc-cart-session.php b/includes/class-wc-cart-session.php index ea8023a72b2..66e5382f266 100644 --- a/includes/class-wc-cart-session.php +++ b/includes/class-wc-cart-session.php @@ -130,6 +130,11 @@ final class WC_Cart_Session { } } + // If it's not empty, it's been already populated by the loop above + if ( ! empty( $cart_contents ) ) { + $this->cart->set_cart_contents( apply_filters( 'woocommerce_cart_contents_changed', $cart_contents ) ); + } + do_action( 'woocommerce_cart_loaded_from_session', $this->cart ); if ( $update_cart_session || is_null( WC()->session->get( 'cart_totals', null ) ) ) { diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index ae5f00e5aaf..863c8c23ef0 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -1093,6 +1093,8 @@ class WC_Cart extends WC_Legacy_Cart { ); } + $this->cart_contents = apply_filters( 'woocommerce_cart_contents_changed', $this->cart_contents ); + do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ); return $cart_item_key;