In WooCommerce, I am using WooCommerce subscriptions plugin, and I'm trying to replace from the subscription price string the text "every 3 days" with "Twice a Week" in single product pages.
This is my code attempt:
function replace_single_product_table_text( $content ) {
if ( is_product() ) {
preg_match_all( '/<table[^>]*class="[^"]*shop_table[^"]*"[^>]*>(.*?)<\/table>/s', $content, $matches );
foreach ( $matches[0] as $match ) {
$new_content = str_replace( 'every 3 days', 'Twice a Week', $match );
$new_content = str_replace( '/ week', '/ Week', $new_content );
$new_content = str_replace( 'one a Week', 'Once a Week', $new_content );
$content = str_replace( $match, $new_content, $content );
}
}
return $content;
}
add_filter( 'the_content', 'replace_single_product_table_text', 99 );
Unfortunately, it doesn't work at all.
Any help will be appreciated.