Automattic\WooCommerce\Internal\Admin
ShippingLabelBannerDisplayRules::order_has_shippable_products
Checks if there's a shippable product in the current order.
Method of the class: ShippingLabelBannerDisplayRules{}
No Hooks.
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->order_has_shippable_products();
ShippingLabelBannerDisplayRules::order_has_shippable_products() ShippingLabelBannerDisplayRules::order has shippable products code WC 10.3.5
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;
}