Merge pull request #20187 from therealgilles/master
Allow to display the checkout (page or shortcode) even when the cart is empty
This commit is contained in:
commit
ebcdd5fde3
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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' );
|
||||
|
|
Loading…
Reference in New Issue