diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index ee2496f08b2..b3f7ff2cda2 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -274,7 +274,7 @@ class WC_AJAX { wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); - if ( WC()->cart->is_empty() && ! is_customize_preview() ) { + if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_update_order_review_expired', true ) ) { self::update_order_review_expired(); } diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index 527a1e0f09e..88cad281c22 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -211,7 +211,7 @@ class WC_Shortcode_Checkout { */ private static function checkout() { // Check cart has contents. - if ( WC()->cart->is_empty() && ! is_customize_preview() ) { + if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) { return; } diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 22c47c64c46..c2ccd854a7b 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -22,7 +22,7 @@ function wc_template_redirect() { wp_safe_redirect( get_post_type_archive_link( 'product' ) ); exit; - } elseif ( is_page( wc_get_page_id( 'checkout' ) ) && wc_get_page_id( 'checkout' ) !== wc_get_page_id( 'cart' ) && WC()->cart->is_empty() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) && ! is_customize_preview() ) { + } elseif ( is_page( wc_get_page_id( 'checkout' ) ) && wc_get_page_id( 'checkout' ) !== wc_get_page_id( 'cart' ) && WC()->cart->is_empty() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) { // When on the checkout with an empty cart, redirect to cart page. wc_add_notice( __( 'Checkout is not available whilst your cart is empty.', 'woocommerce' ), 'notice' );