Automattic\WooCommerce\Internal\Admin
ShippingLabelBanner::count_shippable_items
Count shippable items
Метод класса: ShippingLabelBanner{}
Хуков нет.
Возвращает
int.
Использование
// private - только в коде основоного (родительского) класса $result = $this->count_shippable_items( $order );
- $order(WC_Order) (обязательный)
- Current order.
Код ShippingLabelBanner::count_shippable_items() ShippingLabelBanner::count shippable items WC 11.0.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;
}