From c451ccf83616242a39be16f34119f40727fb0824 Mon Sep 17 00:00:00 2001 From: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:03:07 -0700 Subject: [PATCH] Change the logic flow for the order confirmation thankyou screen On the heels of #38983 and #39191, this changes the flow a bit so that the "thank you" message will always be shown when loading the "order received" URL. However, the verification requirement still prevents the details of the order being shown unless the customer is verified, either by confirming the email or by logging in. If unverified, the login/email form is shown on the thank you screen instead of the order details. --- .../class-wc-shortcode-checkout.php | 26 ++---- .../templates/checkout/thankyou.php | 83 ++++++++++++------- 2 files changed, 63 insertions(+), 46 deletions(-) diff --git a/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php b/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php index 96903d1f7470..adde3eda3f7a 100644 --- a/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php @@ -297,29 +297,19 @@ private static function order_received( $order_id = 0 ) { return; } + $template_args = array( 'order' => $order ); $order_customer_id = $order->get_customer_id(); - // For non-guest orders, require the user to be logged in before showing this page. - if ( $order_customer_id && get_current_user_id() !== $order_customer_id ) { - wc_print_notice( esc_html__( 'Please log in to your account to view this order.', 'woocommerce' ), 'notice' ); - woocommerce_login_form( array( 'redirect' => $order->get_checkout_order_received_url() ) ); - return; - } - - // For guest orders, request they verify their email address (unless we can identify them via the active user session). - if ( self::guest_should_verify_email( $order, 'order-received' ) ) { - wc_get_template( - 'checkout/form-verify-email.php', - array( - 'failed_submission' => ! empty( $_POST['email'] ), // phpcs:ignore WordPress.Security.NonceVerification.Missing - 'verify_url' => $order->get_checkout_order_received_url(), - ) - ); - return; + if ( ! $order_customer_id && self::guest_should_verify_email( $order, 'order-received' ) ) { + // For guest orders, request they verify their email address (unless we can identify them via the active user session). + $template_args['needs_verification'] = 'email'; + } elseif ( $order_customer_id && get_current_user_id() !== $order_customer_id ) { + // For non-guest orders, require the user to be logged in before showing this page. + $template_args['needs_verification'] = 'login'; } // Otherwise, display the thank you (order received) page. - wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) ); + wc_get_template( 'checkout/thankyou.php', $template_args ); } /** diff --git a/plugins/woocommerce/templates/checkout/thankyou.php b/plugins/woocommerce/templates/checkout/thankyou.php index 35f457bc67fd..10c151fd7ca3 100644 --- a/plugins/woocommerce/templates/checkout/thankyou.php +++ b/plugins/woocommerce/templates/checkout/thankyou.php @@ -12,7 +12,7 @@ * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce\Templates - * @version 3.7.0 + * @version 8.0.0 */ defined( 'ABSPATH' ) || exit; @@ -41,43 +41,70 @@

- + + get_payment_method(), $order->get_id() ); ?> + get_id() ); ?> + + + +