I want to remove the word “for”, the pricing + discount sale and only display the subscription options like “Delivery every month” and “Delivery every 2 months,” etc.
I’ve managed to change the text, but I’m having trouble removing the pricing. Here’s the hook I’m using.
function wc_subscriptions_custom_price_string( $price_string ) {
// First, replace 'every' with 'Delivery every'
$new_price = str_replace('every', 'Delivery every', $price_string);
// Now, use a regular expression to remove ' months for $X.XX'
// This assumes that the price is always in the format of $ followed by any number of digits, a dot, and exactly two digits
$new_price = preg_replace('/ months for $d+.d+/', '', $new_price);
// Optionally, if you also want to remove the '(10% off)' part, you can add another line like this:
// $new_price = preg_replace('/ (.*?% off)/', '', $new_price);
return $new_price;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );