Jump to content


Replying to Is There A Way To Change The Inventory Message?


Post Options

  or Cancel


Topic Summary

Elise Alley

Posted 05 June 2014 - 04:13 PM

Happy to have helped, tblocke!

Let us know if you have any other questions!

Thanks,

Elise

tblocke

Posted 05 June 2014 - 04:11 PM

That's what it was...works perfectly!

Thanks again!

Elise Alley

Posted 05 June 2014 - 03:37 PM

Hi tblocke,

It's working on my site:

Screen Shot 2014-06-05 at 4.34.57 PM.png

I think some of the apostrophes might have not converted correctly to plain text when I pasted into this post, though, so try this:

function my_translated_text_strings( $translated_text, $untranslated_text, $domain ) {
$translated_text = $untranslated_text;
if ( 'LION' === $domain || 'it-l10n-ithemes-exchange' === $domain ) {
switch ( $untranslated_text ) {
case 'Product is currently out of stock.' :
$translated_text = 'This course is full.';
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'my_translated_text_strings', 10, 3 );
add_filter( 'ngettext', 'my_translated_text_strings', 10, 3 );

If that doesn't work for you, it might be an issue on your site.  Can you please (always :)) provide us with the URL for your site?

Thanks,

Elise

tblocke

Posted 05 June 2014 - 03:30 PM

Thanks for the code.  Unfortunately, all pages on the site go blank (white, no errors) when adding this code.

Elise Alley

Posted 05 June 2014 - 03:13 PM

Hi tblocke,

There isn't an option to do this in the Product Variants add-on.  

I do have some code that may work for you though.  Try adding this to the bottom of your child theme's functions.php file (before the closing ?> if there is one):

function my_translated_text_strings( $translated_text, $untranslated_text, $domain ) {
$translated_text = $untranslated_text;
if ( 'LION' === $domain || 'it-l10n-ithemes-exchange' === $domain ) {
switch ( $untranslated_text ) {
case 'Product is currently out of stock.' :
$translated_text = ‘This course is full.’;
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'my_translated_text_strings', 10, 3 );
add_filter( 'ngettext', 'my_translated_text_strings', 10, 3 );

Give that a try and let us know how it goes.

Thanks,

Elise

tblocke

Posted 05 June 2014 - 02:22 PM

Hi,

Instead of displaying "This product is out of stock" when the inventory becomes 0, is there a way to customize this message?

For example, if running an online course, have it display "This course is full".

Thanks.

Review the complete topic (launches new window)