WC_Cart::get_cart_contents_weight()

Get weight of items in the cart.


Description Description


Return Return

(float)


Top ↑

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 );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.