25% off ProSNIPC25OFF

Custom WooCommerce Thank-You Page Message

Displays a personalised thank-you message with the customer's first name on the order confirmation page.

PHPby SnipCraft
php
<?php
if ( ! class_exists( 'WooCommerce' ) ) {
    return;
}
add_action( 'woocommerce_thankyou', 'scseed_wc_custom_thankyou_message', 1 );
function scseed_wc_custom_thankyou_message( $order_id ) {
    $order      = wc_get_order( $order_id );
    if ( ! $order ) {
        return;
    }
    $first_name = esc_html( $order->get_billing_first_name() );
    echo '<p class="scseed-thankyou">'
        . sprintf(
            /* translators: %s: customer first name */
            esc_html__( 'Thank you, %s! Your order is confirmed and we will be in touch shortly.', 'textdomain' ),
            $first_name
          )
        . '</p>';
}
#checkout#frontend#orders#ux#woocommerce