Skip to content

Instantly share code, notes, and snippets.

@DxDiagDx
Created March 28, 2021 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DxDiagDx/67ef10e56e5282773c081727d9874364 to your computer and use it in GitHub Desktop.
Save DxDiagDx/67ef10e56e5282773c081727d9874364 to your computer and use it in GitHub Desktop.
Woo: перевод на русский язык единиц измерения
add_filter('woocommerce_format_weight', 'localize_weight_units');
function localize_weight_units($weight) {
if ( strpos($weight, 'kg') !== false ) {
return str_replace('kg', 'кг', $weight);
}
else {
return str_replace('g', 'гр', $weight);
}
}
add_filter('woocommerce_format_dimensions', 'localize_dimensions_units');
function localize_dimensions_units($dimensions) {
if ( strpos($dimensions, 'cm') !== false ) {
return str_replace('cm', 'см', $dimensions);
}
elseif ( strpos($dimensions, ' mm') !== false ) {
return str_replace(' mm', ' мм', $dimensions);
}
else {
return str_replace(' m', ' м', $dimensions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment