Skip to content

Commit

Permalink
Checkout: show "thank you" message regardless of verification status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coreymckrill authored and samueljseay committed Aug 18, 2023
1 parent ad94610 commit be605c0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ private static function order_received( $order_id = 0 ) {

// 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;
}

// 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(
Expand Down
39 changes: 39 additions & 0 deletions plugins/woocommerce/templates/checkout/order-received.php
Original file line number Diff line number Diff line change
@@ -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>
8 changes: 5 additions & 3 deletions plugins/woocommerce/templates/checkout/thankyou.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -39,7 +41,7 @@

<?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">

Expand Down Expand Up @@ -81,7 +83,7 @@

<?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; ?>

Expand Down

0 comments on commit be605c0

Please sign in to comment.