• Resolved cbrennanvin

    (@cbrennanvin)


    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]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @cbrennanvin,

    I understand that you are using the premium plugin Woo Subscriptions here.

    To align with?forum best practices, we don’t provide premium plugin support on this forum. However, if you have a valid license with us, you can open a support request for us to investigate further about your issue.

    Meanwhile, I will mark this thread as resolved since your concern would be best handled by our Happiness Engineers there.

    Thanks!

    Thread Starter cbrennanvin

    (@cbrennanvin)

    I do have a license. Funny, when I reached out to premium support, they suggested going here. smh

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @cbrennanvin,

    Could you please share your ticket number so we can look into this further? Also, did they direct you here for custom development assistance, or did you come for support?

    Furthermore, I see you’ve already posted this question on StackOverflow, which is fantastic! Some of the other developers have started to jump in and help.

    By the way, I can see that you’ve been trying to use a hook to accomplish this. Your approach is correct, but it seems like there might be an issue with your regular expression (regex).

    Please note that writing or providing custom code is not within the scope of our support policy. If you still need assistance, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @cbrennanvin,

    I’ve checked your ticket #7829742 and noticed that you’ve been guided to a different community for development-related support.

    As explained earlier, this particular forums are meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to hide price and discount text from WooCommerce subscription dropdown optio’ is closed to new replies.