From 10046cb8a195e6aac442655b1088db7ff014144b Mon Sep 17 00:00:00 2001 From: Max Rice Date: Fri, 4 Jul 2014 17:22:58 -0400 Subject: [PATCH] Only print checkout notices when not reloading the checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Any notices that are added during checkout are immediately lost when the checkout is forced to reload. This commit fixes that by only printing the notices if the checkout is not being reloaded, otherwise they’re printed on the page reload and properly displayed to the user. --- includes/class-wc-checkout.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 6e81a4d94c7..6208ff0fc5c 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -669,14 +669,19 @@ class WC_Checkout { // If we reached this point then there were errors if ( is_ajax() ) { - ob_start(); - wc_print_notices(); - $messages = ob_get_clean(); + // only print notices if not reloading the checkout, otherwise they're lost in the page reload + if ( ! isset( WC()->session->reload_checkout ) ) { + + ob_start(); + wc_print_notices(); + $messages = ob_get_clean(); + } + echo '' . json_encode( array( 'result' => 'failure', - 'messages' => $messages, + 'messages' => isset( $messages ) ? $messages : '', 'refresh' => isset( WC()->session->refresh_totals ) ? 'true' : 'false', 'reload' => isset( WC()->session->reload_checkout ) ? 'true' : 'false' )