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:
Claudiu Lodromanean 2018-06-11 13:57:02 -07:00 committed by GitHub
commit ebcdd5fde3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -274,7 +274,7 @@ class WC_AJAX {
wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); 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(); self::update_order_review_expired();
} }

View File

@ -211,7 +211,7 @@ class WC_Shortcode_Checkout {
*/ */
private static function checkout() { private static function checkout() {
// Check cart has contents. // 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; return;
} }

View File

@ -22,7 +22,7 @@ function wc_template_redirect() {
wp_safe_redirect( get_post_type_archive_link( 'product' ) ); wp_safe_redirect( get_post_type_archive_link( 'product' ) );
exit; 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. // 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' ); wc_add_notice( __( 'Checkout is not available whilst your cart is empty.', 'woocommerce' ), 'notice' );