Ecommerce Shopify WordPress Discussion

Translation string not working for WooCommerce product up-sells heading

I recently used this bit of code to translate the WooCommerce bits that other translation plugin didn't pick up - however, this code doesn't seem to work on some strings like this one. Any idea why it doesn't work? Loco translate didn't work on this one, and while the filter code was working on 95% of other untranslated strings, this one remained stubborn. // Alter WooCommerce View Cart Text add_filter( 'gettext', function( $translated_text ) { if ( 'You may also like…' === $translated_text ) { $translated_text = 'To moze Ci sie spodobac'; } return $translated_text; } );
You can use woocommerce_product_upsells_products_heading related available filter hook: add_filter( 'woocommerce_product_upsells_products_heading', 'filter_product_upsells_products_heading' ); function filter_product_upsells_products_heading( $heading_text ) { return 'To moze Ci sie spodobac'; } Or your revised code (where "…" character requires being replaced with …): add_filter( 'gettext', 'change_product_upsells_heading_text', 10, 3 ); function change_product_upsells_heading_text( $translated_text, $original_text, $domain ) { if( 'You may also like…' === $original_text ) { $translated_text = 'To moze Ci sie spodobac'; } return $translated_text; } Code goes on functions.php file of your child theme (or in a plugin). Both ways work.

February 26, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.