Last active
January 27, 2017 08:26
-
-
Save barrykooij/80b87022c23874511cad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment