Forum Replies Created

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)