Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Created July 29, 2013 13:33
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/6104328 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/6104328 to your computer and use it in GitHub Desktop.
WooCommerce - Display cart total weight on the cart page
<?php
/**
* WooCommerce
* --------------
*
* Display cart total weight on the cart page
*
*/
add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info');
function myprefix_cart_extra_info() {
global $woocommerce;
echo '<div class="cart-extra-info">';
echo '<p class="total-weight">' . __('Total Weight:', 'woocommerce');
echo ' ' . $woocommerce->cart->cart_contents_weight . ' ' . get_option('woocommerce_weight_unit');
echo '</p>';
echo '</div>';
}
@alexd0001
Copy link

Hi thanks for this! - Do you know how can i set the weight with a "comma" "," instead a "dot" "."? - alex

@protorob
Copy link

Super nice snippet, thanks.
Any suggestion on how to maker it update with the ajax cart?
It only update the value when the page is reffreshed.
Thanks in advance.

@nbvcw
Copy link

nbvcw commented Jan 21, 2020

Hello @protorob , were you able to find a solution for your query ? I'm having the same problem and were wondering if you could share your findings with me, if you don't mind. Thanks, -nbvcw

@ospiotr
Copy link

ospiotr commented Jan 30, 2020

Hi @nbvcw - you can use this plugin instead: https://wordpress.org/plugins/woo-cart-weight/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment