This script redirect to my account page if in the order there's a subscription product
<?php
if ( function_exists( 'YITH_WC_Subscription' ) ) {
add_action( 'woocommerce_before_template_part', 'test', 10, 4 );
function test( $template_name, $template_path, $located, $args ) {
if ( $template_name == 'checkout/thankyou.php' ) {
if ( isset( $args['order'] ) ) {
$order = $args['order'];
foreach ( $order->get_items() as $item ) {
if ( YITH_WC_Subscription()->is_subscription( $item['product_id'] ) ) {
wp_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
}
}
}
}
}
}