Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

How to Display Weight at WooCommerce Cart

If you’re using WooCommerce and you either want the weight or dimension of a product to show up, or if you even just want to use it for shipping, it can be a serious headache when you can’t figure out how to make the weight appear or you might want to show what is the current Cart Weight on the cart. So here you go!

Add this code in your theme’s functions.php file of your active child theme (or theme).

add_action('woocommerce_before_checkout_form', 'print_cart_weight');
add_action('woocommerce_before_cart', 'print_cart_weight');
 
function print_cart_weight( $posted ) {
global $woocommerce;
$notice = 'Your cart weight is: ' . $woocommerce->cart->cart_contents_weight . get_option('woocommerce_weight_unit');
if( is_cart() ) {
    wc_print_notice( $notice, 'notice' );
} else {
    wc_add_notice( $notice, 'notice' );
}
}
Exit mobile version