0

I'm using the WooCommerce Waitlist plugin, but I'd like to change it to be for products that haven't been released yet, ie for "expressions of interest".

To do this I need to change a lot of strings, for example one that says "Join the waitlist to be emailed when this product becomes available".

I've found where this is set in the plugin: the file...

wcwl-waitlist-template-functions.php

... in the root folder of the plugin.

If this was a theme I could replicate this file in my child theme and modify the strings, but as it's a plugin I'm all out at sea. And redeclaring the function causes an error. Any help would be much appreciated.

Here's the code of the function...

/**
 * Get the default intro text to display above the waitlist dependent on product type
 *
 * @param string $product_type simple/variation/grouped (variation is the same as simple by default)
 * @param bool   $user_is_on_waitlist
 *
 * @return mixed|void
 */
function wcwl_get_intro_text( $product_type = 'simple', $user_is_on_waitlist = false ) {
    $context = 'join';
    $text    = __( 'Join the waitlist to be emailed when this product becomes available', 'woocommerce-waitlist' );
    if ( $user_is_on_waitlist ) {
        $context = 'leave';
        $text    = __( 'You are on the waitlist for this product', 'woocommerce-waitlist' );
    } elseif ( 'grouped' === $product_type || 'event' === $product_type ) {
        $context = $product_type;
        $text    = __( 'Check the box alongside any Out of Stock products and update the waitlist to be emailed when those products become available', 'woocommerce-waitlist' );
    }

    return apply_filters( 'wcwl_' . $context . '_waitlist_message_text', $text );
}
1

You are able to change texts using a translation file.

By default, plugin texts are in the English language. Even your site language is English, You are able to generate a new language file and change texts on it.

Imagine that the plugin folder name (plugin slug, plugin text domain) is my-plugin and Your site language is set to English (UK) in Admin Dashboard -> Settings -> General Settings -> Site Language.

So, Create a new translation using Poedit and set the translation language to English (UK). Then change texts as You want and save the translation file. You can use the pot file that comes with the plugin and most of the time it exists in the language folder.

It will give You two files named as en_GB.po and en_GB.mo. Rename files to my-plugin-en_GB.po and my-plugin-en_GB.mo and move them to wp-content/languages/plugins folder. Refresh the site and texts should be changed.

  • Thanks @Hector, I've managed to use this approach for most strings, however for some (such as the above) the translation didn't work, so for these I needed to apply Chetan Vaghela's approach. – clayRay - Reinstate Monica Oct 23 at 5:09
0

You can change text using filter. add below code in active theme's functions.php file to change text form join waitlist message. Here is a documentation where you can take reference. : https://docs.woocommerce.com/document/woocommerce-waitlist/

add_filter( 'wcwl_join_waitlist_message_text', 'change_string_from_woo_wait_list',10,1 );
function change_string_from_woo_wait_list($text)
{
    $text = __( 'Custom Text' ); // change text here
    return $text;
}

Let me know if this works for you!

  • Thanks @Chetan_Vaghela, this is a good approach for targeting a small number of strings (I don't know why someone downvoted your answer). Because I had a lot of strings to change I mainly used Hector's approach, but because some translations didn't work, I had to use your approach as well. It's a shame I can't mark both answers as correct! – clayRay - Reinstate Monica Oct 23 at 5:12
  • 1
    It's okay. somebody down-voted my answer. i have followed approach given by plugin documentation. i thought it is proper way to do change string using filter action which is provided by plugin. – Chetan Vaghela Oct 23 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.