WC_Cart::get_cart_contents_weight()
Get weight of items in the cart.
Description Description
Return Return
(float)
Source Source
File: includes/class-wc-cart.php
public function get_cart_contents_weight() {
$weight = 0;
foreach ( $this->get_cart() as $cart_item_key => $values ) {
if ( $values['data']->has_weight() ) {
$weight += (float) $values['data']->get_weight() * $values['quantity'];
}
}
return apply_filters( 'woocommerce_cart_contents_weight', $weight );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |