Dynamic subject for customer_payment_retry email

I need to programmatically change the subject of the email sent to the customer with the id “customer_payment_retry” and the body of the email.

For the subject I’m using the filter “woocommerce_subscriptions_email_subject_customer_retry” but it doesn’t seem to work, here’s the code I’m using:

function change_email_subject_customer_retry( $subject, $order ) {
	$count_attempts=\WCS_Retry_Manager::store()->get_retry_count_for_order( $order->get_id() );
	return $subject . ' attempt #' . $count_attempts; 
add_filter('woocommerce_subscriptions_email_subject_customer_retry', 'change_email_subject_customer_retry', 11, 2);

I added this code in the child-theme “<child-theme-folder>/woocommerce/emails/customer-payment-retry.php”

What am I doing wrong?


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer