Automattic\WooCommerce\Internal\Admin
ShippingLabelBannerDisplayRules::order_has_shippable_products
Checks if there's a shippable product in the current order.
Метод класса: ShippingLabelBannerDisplayRules{}
Хуков нет.
Возвращает
true|false.
Использование
// private - только в коде основоного (родительского) класса $result = $this->order_has_shippable_products();
Код ShippingLabelBannerDisplayRules::order_has_shippable_products() ShippingLabelBannerDisplayRules::order has shippable products WC 10.8.1
private function order_has_shippable_products() {
$order = wc_get_order();
if ( ! $order ) {
return false;
}
// At this point (no packaging data), only show if there's at least one existing and shippable product.
foreach ( $order->get_items() as $item ) {
if ( $item instanceof \WC_Order_Item_Product ) {
$product = $item->get_product();
if ( $product && $product->needs_shipping() ) {
return true;
}
}
}
return false;
}