Skip to content

Commit

Permalink
Merge pull request woocommerce#20187 from therealgilles/master
Browse files Browse the repository at this point in the history
Allow to display the checkout (page or shortcode) even when the cart is empty
  • Loading branch information
claudiulodro committed Jun 11, 2018
2 parents 2c1c32b + 3818598 commit ebcdd5f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/class-wc-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static function update_order_review() {

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();
}

Expand Down
2 changes: 1 addition & 1 deletion includes/shortcodes/class-wc-shortcode-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static function order_received( $order_id = 0 ) {
*/
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;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/wc-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit ebcdd5f

Please sign in to comment.