You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WooCommerce商品页附加信息栏修改及单位转换需求咨询

Absolutely, both of your requests are totally doable with custom code snippets for WooCommerce—no need to edit core files (which is always a good practice to keep things update-safe). Let’s walk through each task:

1. Rename "Dimensions" to "Box Dimensions" in Additional Information

WooCommerce has a built-in filter that lets you override the dimensions label. Just add this code to your theme’s functions.php file, or use a custom code plugin (like Code Snippets) to avoid losing changes when you update your theme:

add_filter( 'woocommerce_product_dimensions_label', 'change_dimensions_label_to_box_dimensions' );
function change_dimensions_label_to_box_dimensions() {
    return __( 'Box Dimensions', 'woocommerce' );
}

This hooks into the label output and replaces the default "Dimensions" text with "Box Dimensions" across all product pages.

2. Display Product Weight in Kilograms (KG) Instead of Grams

To convert the stored gram weight to kilograms for front-end display, use the woocommerce_get_product_weight filter. This snippet will take the gram value, divide by 1000, format it nicely, and append the KG unit:

add_filter( 'woocommerce_get_product_weight', 'convert_grams_to_kg_for_display', 10, 2 );
function convert_grams_to_kg_for_display( $weight, $product ) {
    // Check if the weight exists and your store's base unit is grams
    if ( ! empty( $weight ) && get_option( 'woocommerce_weight_unit' ) === 'g' ) {
        // Convert grams to kg, round to 2 decimal places for readability
        $kg_weight = round( $weight / 1000, 2 );
        // Return the formatted weight with KG unit
        return $kg_weight . ' KG';
    }
    // Fallback to original weight if conditions aren't met
    return $weight;
}

Quick check: Make sure your WooCommerce store’s base weight unit is set to grams (you can verify this in WooCommerce > Settings > Products > General > Weight Unit). If it’s set to something else, tweak the condition in the code to match your setup.

Both snippets will work seamlessly in the Additional Information tab, as well as any other spots where product dimensions/weight show up on your site.

内容的提问来源于stack exchange,提问作者Jonny B'Good

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:37:08