In WooCommerce I would like to change cm to ft my products display in height, width and length,
You can see the products with their title below:
In WooCommerce I would like to change cm to ft my products display in height, width and length,
You can see the products with their title below:
Try the following code that will change the displayed dimensions unit in front end:
add_filter( 'woocommerce_format_dimensions', 'custom_dimention_unit', 20, 2 );
function custom_dimention_unit( $dimension_string, $dimensions ){
$dimension_string = implode( ' x ', array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ) );
if ( ! empty( $dimension_string ) ) {
$dimension_string .= ' ' . __('ft');
} else {
$dimension_string = __( 'N/A', 'woocommerce' );
}
return $dimension_string;
}
Code goes in function.php file of your active child theme (or active theme).
Update: Make dimension unit "ft" (feet) globally (everywhere)
Woocommerce dimension available units are "m", "cm", "mm", "in" and "yd".
But "ft" is not available in the Woocommerce > Settings > Products > Mesurements section.
What you can do is the following:
Paste the following line in your function.php file and save:
update_option( 'woocommerce_dimension_unit', 'ft' );
Browse any page of your web site.
You will get something like:
And in backend:
For info, to change the dimensions unit in Woocommerce > Settings > Products: