qTranslate-Team / woocommerce-qtranslate-x

Enables multilingual framework for plugin "WooCommerce - excelling eCommerce".

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Product archive description not translated

soft79 opened this issue · comments

WooCommerce fetches the archive content this way:

wc-template-functions.php function woocommerce_product_archive_description():

$shop_page   = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
    $description = wc_format_content( $shop_page->post_content );
    if ( $description ) {
        echo '<div class="page-description">' . $description . '</div>';
    }
}

If displayed by the theme, you see the [:en]raw[:] content.

changing WooCommerce to do it this way fixes the issue:
$description = wc_format_content( apply_filters('the_content', $shop_page->post_content) );

but can it be fixed by adding some kind of hook in WooCommerce qTranslate X ?

Hi @josk79, I could not find an existent filter to enable for this case so far. Could you test on your configuration, to change function in woocommerce/includes/wc-formatting-functions.php

function wc_format_content( $string ) {
return do_shortcode( shortcode_unautop( wpautop( $string ) ) );
}

as this

function wc_format_content( $string ) {
return apply_filters('woocommerce_format_content', do_shortcode( shortcode_unautop( wpautop( $string ) ) ));
}

and then add 'woocommerce_format_content' to the array $use_filters in woocommerce-qtranslate-x/qwc-front.php.

If this works well for you, submit this change to https://github.com/woothemes/woocommerce, they are friendly on new filters and their next release will have it.

Actually, when you submit to Woocommerce, this version would be more flexible, just in case:

function wc_format_content( $string ) {
$w=wpautop( $string );
$s=shortcode_unautop( $w );
return apply_filters('woocommerce_format_content', do_shortcode($s), $string, $w, $s);
}

I made a copy/paste error in the solution in the first post, just fixed it.

What do you think about this:
wc_format_content( apply_filters('the_content', $shop_page->post_content) );

This they may oppose, since it may have an effect on others.

It is safe to make a change that does nothing to the current users, otherwise they will be hesitant. A new filter at that place would be fine, but I think my version is more advantageous to us and possibly to others since it provides a common flexibility.

Besides, there might be other uses of wc_format_content, including their future development, which we have not caught yet, but some day somebody will ;)

Yes you're right. That makes sense...