Jiří Prek
Jiří Prek

Reputation: 93

Product formatted dimensions display "×" instead of "x" in Woocommerce 3

I have such a problem with woocommerce plugin. Since last upgrade of woocommerce to last version I can see "×" instad "x" in dimension section in variant product. So I can see for ex. "&15times;15×15cm" instead "15 x 15 x 15cm".

Official support recommends me to disable every plugin (try to plugin conflict) and activate storefront theme. I trie both of theese solvings and still no success (this means that problem could be in original woocommerce plugin). You can watch screenshot of this issue here: enter link description here

Thanks for help

Upvotes: 3

Views: 1023

Answers (2)

Artios Media
Artios Media

Reputation: 1

It's been fixed at code level by Automattic on Nov. 8, 2018. The problem has nothing to do with another plugin. A filter hook hack added to the function.php fix is just more junk code--skip that suggestion. You can either fix it manually or wait until the next update. https://github.com/woocommerce/woocommerce/pull/21833 Use this code to fix the file includes/wc-formatting-functions.php: https://github.com/woocommerce/woocommerce/pull/21833/files. Solves the problem completely.

Upvotes: 0

LoicTheAztec
LoicTheAztec

Reputation: 253901

You can use the following function hooked in woocommerce_format_dimensions filter hook to make the changes that you need this way (in the last line):

add_filter( 'woocommerce_format_dimensions', 'change_formated_product_dimentions', 10, 2 );
function change_formated_product_dimentions( $dimension_string, $dimensions ){
    if ( empty( $dimension_string ) )
        return __( 'N/A', 'woocommerce' );

    $dimensions = array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) );

    return implode( ' x ',  $dimensions ) . get_option( 'woocommerce_dimension_unit' );
}

Code goes in function.php file of the active child theme (or active theme). Tested and works.

Upvotes: 2

Related Questions