Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Tirane (GMT+02:00)

This topic contains 8 replies, has 2 voices.

Last updated by Marsel Nikolli 1 year, 1 month ago.

Assisted by: Marsel Nikolli.

Author Posts
March 25, 2024 at 10:39 am #15445827

alexanderH-96

On our product page, one string won't translate in the front end although it shows as translated. On this product page (hidden link), where it says "incl. VAT, FREE SHIPPING" right under the buy button, when changing the language, it's still in English.

March 25, 2024 at 11:34 am #15446242

Marsel Nikolli

Hi,

Thank you for contacting WPML Support, I will gladly help you.

From the debug info you provided, I noticed that you have WPML v4.6.5 installed, I suggest you install the latest version(v4.6.9). Also, please update any other plugins that might need updating.

After that, clear your website's cache (server-side included) and check if the issue persists.

* Note: Please make sure you have a full backup of your website before making any updates/changes to your website.

Looking forward to your reply,
Marsel

March 25, 2024 at 4:42 pm #15448309

alexanderH-96

Hi Marsel,

I updated WPML and all important plugins. I purched cache but the problem persists.

March 26, 2024 at 8:40 am #15449907

Marsel Nikolli

Hi,

Thank you for the update.

I would need temporary access to your site's WP admin to investigate this issue and understand it better.

Please fully back up your site (files and database) and confirm it in your next reply.

Your next reply is set to private for you to provide the username and password details.

Thanks,
Marsel

March 27, 2024 at 9:24 am #15454173

Marsel Nikolli

Hi,

Thank you for the access.

Can you please tell me if you are using any custom PHP function to add that string to the website?

* In WPML -> String Translation, I noticed that the string was included via a function on functions.php of your theme.

Looking forward to your reply,
Marsel

March 27, 2024 at 2:41 pm #15456323

alexanderH-96

I found this in the functions.php:

{
// Only on sale products on frontend and excluding min/max price on variable products
if ($product->is_on_sale() && !is_admin()) {
// Get product prices
$regular_price = (float)$product->get_regular_price(); // Regular price
$sale_price = (float)$product->get_price(); // Active price (the "Sale price" when on-sale)

$saving_percentage = round(100 - ($sale_price / $regular_price * 100), 0) . '%';

// Append to the formated html price
$price .= sprintf(__('<p class="saved-sale"><span class="discount">%s OFF</span></p>', 'woocommerce'), $saving_percentage);
}
if (!is_admin()) $price .= __('<div class="after-price"><p class="include-ship">incl. VAT, </p>FREE SHIPPING</div>');
return $price;
}

So yes, it seems to be inserted via PHP. But it should still be translatable, right?

March 27, 2024 at 3:14 pm #15456702

Marsel Nikolli

Hi,

We can not support or debug custom-coded solutions as per our policy, I will do my best to suggest a correct approach.

I've checked the code and please try the code below and check if it helps resolving the issue:

add_filter('woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2);

function change_displayed_sale_price_html($price, $product) {
    // Only on sale products on frontend and excluding min/max price on variable products
    if ($product->is_on_sale() && !is_admin()) {
        // Get product prices
        $regular_price = (float)$product->get_regular_price(); // Regular price
        $sale_price = (float)$product->get_price(); // Active price (the "Sale price" when on-sale)

        $saving_percentage = round(100 - ($sale_price / $regular_price * 100), 0) . '%';

        // Append to the formatted html price
        $price .= sprintf('<p class="saved-sale"><span class="discount">%s OFF</span></p>', $saving_percentage);
    }
    
    if (!is_admin()) {
        $price .= '<div class="after-price"><p class="include-ship">' . __('incl. VAT, FREE SHIPPING', 'woocommerce') . '</p></div>';
    }
    
    return $price;
}

Please note that the code provided should serve only as a guide to help you achieve what you seek. Please test the code provided on a staging site if possible.

* If you need custom coding I suggest using WPML contractor's service: https://wpml.org/contractors/

I hope I was helpful. Don't hesitate to ask if you have any doubts along the way, I'll gladly help you.

Kind regards,
Marsel

March 27, 2024 at 4:15 pm #15457150

alexanderH-96

Hey there, unfortunately the code didn't work. It broke the design a little bit and the translation still didn't show.

March 27, 2024 at 4:26 pm #15457194

Marsel Nikolli

Hi,

Normally the string should be showing under the domain "woocommerce", as the text-domain used:

__('incl. VAT, FREE SHIPPING', 'woocommerce')

is 'woocommerce'.

* Please try again in a staging site, and after you apply the code check on WPML -> String Translations for the string "incl. VAT, FREE SHIPPING" under the domain 'woocommerce'. If the string shows up, try translating it and check if it works on front-end.

Let me know how it goes.

The topic ‘[Closed] One string won't translate int he front end although it shows as translated’ is closed to new replies.