diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index 6f231d19a8af9..39230e4a78ce7 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -681,9 +681,11 @@ public function get_undo_url( $cart_item_key ) { */ public function get_cart() { if ( ! did_action( 'wp_loaded' ) ) { - $this->get_cart_from_session(); _doing_it_wrong( __FUNCTION__, __( 'Get cart should not be called before the wp_loaded action.', 'woocommerce' ), '2.3' ); } + if ( ! did_action( 'woocommerce_cart_loaded_from_session' ) ) { + $this->get_cart_from_session(); + } return array_filter( (array) $this->cart_contents ); }