Created
July 29, 2013 13:33
-
-
Save NiklasHogefjord/6104328 to your computer and use it in GitHub Desktop.
WooCommerce - Display cart total weight on the cart page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
} |
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.
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
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
Hi thanks for this! - Do you know how can i set the weight with a "comma" "," instead a "dot" "."? - alex