How to hide price and discount text from WooCommerce subscription dropdown optio

[ad_1]

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.

Instead of this
Choose your frequency dropdown
– Every month for $11.25 (10% off)
– Every 2 months for $11.25 (10% off)
– Every 3 months for $11.25 (10% off)
– Every 4 months for $11.25 (10% off)
– Every 5 months for $11.25 (10% off)
– Every 6 months for $11.25 (10% off)

I need this
Choose your frequency dropdown
– Every month
– Every 2 months
– Every 3 months
– Every 4 months
– Every 5 months
– Every 6 months

My code. I can change the the string text but I cannot remove the pricing. That’s been my biggest challenge. Using regex is giving me a page error about unknown modifier. Error below:

function wc_subscriptions_custom_price_string( $price_string ) {
    // Replace 'every' with 'Delivery every'
    $new_price = str_replace('every', 'Delivery every', $price_string);

    // Use regex to remove everything from the dollar sign to the closing </option> tag
    $new_price = preg_replace('/(Every )(month|\d months)(.*?(<\/option>))/gm', "$1$2$4", $price_string);

    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' );
Warning: preg_replace(): Unknown modifier 'g' in /Users/chrisbrennan/Local Sites/dgoods/app/public/wp-content/themes/bricks-child/functions.php on line 319

The page I need help with: [log in to see the link]

 

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