WC_Cart::get_cart_contents_weight
Get weight of items in the cart.
Method of the class: WC_Cart{}
Hooks from the method
Returns
float.
Usage
$WC_Cart = new WC_Cart(); $WC_Cart->get_cart_contents_weight();
Changelog
| Since 2.5.0 | Introduced. |
WC_Cart::get_cart_contents_weight() WC Cart::get cart contents weight code WC 10.3.5
public function get_cart_contents_weight() {
$weight = 0.0;
foreach ( $this->get_cart() as $values ) {
if ( $values['data']->has_weight() ) {
$weight += (float) $values['data']->get_weight() * $values['quantity'];
}
}
return apply_filters( 'woocommerce_cart_contents_weight', $weight );
}