A simple, powerful and independent e-commerce platform.
Sell anything with ease.

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', 'bbloomer_print_cart_weight', 99);
add_action('woocommerce_before_cart', 'bbloomer_print_cart_weight', 99);
 
function bbloomer_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: 1000