Automattic\WooCommerce\Internal\Admin
ShippingLabelBanner::count_shippable_items()
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() ShippingLabelBanner::count shippable items code WC 9.3.3
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; }