Created
November 4, 2020 09:14
-
-
Save yanknudtskov/b2e95cec0506398b1e0196bcb53e10dd to your computer and use it in GitHub Desktop.
Modyfying the WooCommerce Thank You Page Texts
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 | |
add_filter( 'the_title', 'woo_personalize_order_received_title', 10, 2 ); | |
function woo_personalize_order_received_title( $title, $id ) { | |
if ( is_order_received_page() && get_the_ID() === $id ) { | |
global $wp; | |
// Get the order. Line 9 to 17 are present in order_received() in includes/shortcodes/class-wc-shortcode-checkout.php file | |
$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->get_order_key() != $order_key ) { | |
$order = false; | |
} | |
} | |
if ( isset ( $order ) ) { | |
$title = sprintf( "You are awesome, %s!", esc_html( $order->billing_first_name ) ); | |
} | |
} | |
return $title; | |
} | |
add_filter('woocommerce_thankyou_order_received_text', 'yanco_woocommerce_thankyou_order_received_text', 10, 2 ); | |
function yanco_woocommerce_thankyou_order_received_text( $thank_you_text, $order ) { | |
if ( isset ( $order ) ) { | |
$first_name = $order->get_billing_first_name(); | |
$site_name = get_bloginfo( 'name' ); | |
$my_account = '<a href="' . get_permalink( get_option('woocommerce_myaccount_page_id') ) . '">Min konto</a>'; | |
//$thank_you_text = get_field( 'acf_option_thankyou_page_content', 'option' ); | |
//$thank_you_text = str_replace( '{fornavn}', $first_name, $thank_you_text ); | |
//$thank_you_text = str_replace( '{sitename}', $site_name, $thank_you_text ); | |
//$thank_you_text = str_replace( '{myaccount}', $my_account, $thank_you_text ); | |
$thank_you_text .= '</p>'; | |
$thank_you_text .= '<h2>Ordreinformationer</h2>'; | |
} | |
return $thank_you_text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment