Checkout: show "thank you" message regardless of verification status

As an alternative to #39406, this tries to solve the same issue in a
simpler way: break the "thank you" message out into its own small
template file and just include it in more places, so that no matter
the context, the order confirmation screen will always say thank you,
acknowledging that the order data has been received.
This commit is contained in:
Corey McKrill 2023-08-15 14:10:06 -07:00
parent 53b0f113e5
commit 9212d5f70d
No known key found for this signature in database
GPG Key ID: 84BBFE669C4D97B8
3 changed files with 46 additions and 3 deletions

View File

@ -301,6 +301,7 @@ class WC_Shortcode_Checkout {
// 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_get_template( 'checkout/order-received.php', array( 'order' => false ) );
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;
@ -308,6 +309,7 @@ class WC_Shortcode_Checkout {
// 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/order-received.php', array( 'order' => false ) );
wc_get_template(
'checkout/form-verify-email.php',
array(

View File

@ -0,0 +1,39 @@
<?php
/**
* "Order received" message.
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 8.1.0
*/
defined( 'ABSPATH' ) || exit;
/** @var WC_Order|false $order */
?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received">
<?php
/**
* Filter the message shown after a checkout is complete.
*
* @param string $message The message.
* @param WC_Order|false $order The order created during checkout, or false if order data is not available.
*/
$message = apply_filters(
'woocommerce_thankyou_order_received_text',
__( 'Thank you. Your order has been received.', 'woocommerce' ),
$order
);
echo esc_html( $message );
?>
</p>

View File

@ -12,10 +12,12 @@
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.7.0
* @version 8.1.0
*/
defined( 'ABSPATH' ) || exit;
/** @var WC_Order $order */
?>
<div class="woocommerce-order">
@ -39,7 +41,7 @@ defined( 'ABSPATH' ) || exit;
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php wc_get_template( 'checkout/order-received.php', array( 'order' => $order ) ); ?>
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
@ -81,7 +83,7 @@ defined( 'ABSPATH' ) || exit;
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), null ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php wc_get_template( 'checkout/order-received.php', array( 'order' => false ) ); ?>
<?php endif; ?>