• Resolved pabs311

    (@pabs311)


    Hi

    I use sublanguage to translate my woocommerce site. The product are correctly translated. However, on the cart page, in the cart view, the product are shown untranslated. The link points to the translated page, with the right translated slugs, only the product name and description are shown in the default language. Am I missing a configuration here ?

    Thanks a lot!

    • This topic was modified 10 months, 3 weeks ago by pabs311.
Viewing 1 replies (of 1 total)
  • Thread Starter pabs311

    (@pabs311)

    Oops, it seems that an answer for the same issue was already provided 6 years ago in this forum. Posting it here to increase visibility:

    The following snippet in the functions.php will fix the product title not being translated

    add_filter('woocommerce_product_get_name', function($name, $product) {
    
    $post = get_post($product->get_id());
    
    if ($post) {
    
    return apply_filters('sublanguage_translate_post_field', $name, $post, 'post_title');
    
    }
    
    return $name;
    
    }, 10, 2);

    To translate the short description, the following should be added:

    add_filter('woocommerce_product_get_short_description', function($name, $product) {
        $post = get_post($product->get_id());
        if ($post) {
            return apply_filters('sublanguage_translate_post_field', $name, $post, 'post_excerpt');
        }
        return $name;
    }, 10, 2);
Viewing 1 replies (of 1 total)
  • The topic ‘Product not translated in cart’ is closed to new replies.