The thank you or order confirmation page can be customized in different ways, if you want to do without plugins altogether.
1st variant: Via redirection to a separate subpage
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'https://www.zurgewuenschtenseite.de' );
exit;
}
}
2nd variant: Customize the Woocommerce page
// Change the heading
add_filter( 'the_title', 'woo_title_order_received', 10, 2 );
function woo_title_order_received( $title, $id ) {
if ( function_exists( 'is_order_received_page' ) &&
is_order_received_page() && get_the_ID() === $id ) {
$title = "Vielen Dank für Ihre Bestellung und alles andere";
}
return $title;
}
// Change the second heading
add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 );
function woo_change_order_received_text( $str, $order ) {
$new_str = 'Dies steht nun in der zweiten Zeile';
return $new_str;
}
// Forwarding to a separate subpage for a specific product (based on the product ID)
add_action( 'woocommerce_thankyou', 'redirect_product_based', 1 );
function redirect_product_based ( $order_id ){
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
if ( $item['product_id'] == 643 ) {
wp_redirect( 'https://www.weiterleitungzurunterseite' );
}
}
}