Automattic\WooCommerce\Internal\Admin

ShippingLabelBanner::count_shippable_items()privateWC 1.0

Count shippable items

Method of the class: ShippingLabelBanner{}

No Hooks.

Return

Int.

Usage

// private - for code of main (parent) class only
$result = $this->count_shippable_items( $order );
$order(\WC_Order) (required)
Current order.

ShippingLabelBanner::count_shippable_items() code WC 7.1.1

private function count_shippable_items( \WC_Order $order ) {
	$count = 0;
	foreach ( $order->get_items() as $item ) {
		if ( $item instanceof \WC_Order_Item_Product ) {
			$product = $item->get_product();
			if ( $product && $product->needs_shipping() ) {
				$count += $item->get_quantity();
			}
		}
	}
	return $count;
}