|
In Review widget, product names are always in default language
Started by: dmitrijsH
in: English Support
Quick solution available
Problem:
When using the Product Reviews widget, you would see the product name in the wrong language according to the review language.
Solution:
The workaround is adding the following code to your theme functions.php file.
add_filter('woocommerce_product_get_name', 'adjust_product_name_for_reviews', 10, 2);
function adjust_product_name_for_reviews( $name, $product ){
$lang = apply_filters( 'wpml_current_language', NULL );
$id = $product->get_id();
$adjustedid = apply_filters('wpml_object_id', $id, "product", true, $lang);
if ($adjustedid != $id) {
$name = get_the_title( $adjustedid );
}
return $name;
}
After that, the product names will be correct according to the language you visit.
|
|
2 |
11 |
1 year, 10 months ago
dmitrijsH
|