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.
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.
{
// 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)
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.
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.