Hi Guys,
I would like to personalize my thank you page and to do so by using this code:
<?php
function rp4wp_title_order_received( $title, $id ) {
if ( is_order_received_page() && get_the_ID() === $id ) {
global $wp;
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( $order->order_key != $order_key ) {
unset( $order );
}
}
if ( isset ( $order ) ) {
$title = sprintf( "Thank you, %s!", esc_html( $order->billing_first_name ) );
}
}
return $title;
}
add_filter( 'the_title', 'rp4wp_title_order_received', 10, 2 );
I’ve added this code to the functions.php file (2nd rule) in my child theme folder (which is activated in wordpress) I tried a test order to see if it works but I still see the “old” thank you message. Am I doing something wrong? Or do I need to flush all cache to see changes?
Thanks!
Joost