• Resolved ZappoB

    (@zappob)


    Hello,

    how can the alert text displayed for an out of stock composite product be changed or translated and formatted?

    Best regards,
    Zappo

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support miemie

    (@miemie)

    Hi @zappob,

    Please follow this article to change the text in our plugin.

    Regards,

    Thread Starter ZappoB

    (@zappob)

    Hello and thank you for your answer.

    I added the following script with the plugin Snippets:

    add_filter( 'gettext', 'wpc_translations', 99, 2 );
    function wpc_translations( $translation, $text ) {
    	if ( $text === 'Please select a purchasable product in the component' ) {
    		return 'Die gew?hlte Option bei';
    	}
    
    	if ( $text === 'before adding to the cart.' ) {
    		return 'ist aktuell nicht verfügbar';
    	}
    
    	return $translation;
    }

    It seems to have no effect at all: the text is not translated.

    I haven’t tried Loco, as I wanted to stay away from another plugin for just one need.

    Any further suggestions? Did I made a mistake in the script?

    Best Regards,
    Zappo

    Plugin Author WPClever

    (@wpclever)

    Hi,

    Please use below snippet instead:

    add_filter( 'gettext', 'wpc_translations_14548545', 99, 2 );
    function wpc_translations_14548545( $translation, $text ) {
    	if ( $text === 'Please select a purchasable product in the component [name] before adding to the cart.' ) {
    		return 'Die gew?hlte Option bei [name] ist aktuell nicht verfügbar.';
    	}
    
    	return $translation;
    }

    Use the “[name]” in your text to show the dynamic component name.

    Thread Starter ZappoB

    (@zappob)

    Sorry for the late reply, the second snippet works fine.

    Many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Translate “Show alert” text?’ is closed to new replies.