Display total weight on cart and checkout pages

This code displays the total cart weight to the customer on the cart and checkout pages.

		/**
 * Display weight on cart and checkout pages
 */

add_action('woocommerce_before_checkout_form', 'sc_woo_print_cart_weight', 99);
add_action('woocommerce_before_cart', 'sc_woo_print_cart_weight', 99);
 
function sc_woo_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');

  }
}
	
View Raw Code ID: 91000