WC_Abstract_Order::has_free_item
Returns true if the order contains a free product.
Method of the class: WC_Abstract_Order{}
No Hooks.
Returns
true|false.
Usage
$WC_Abstract_Order = new WC_Abstract_Order(); $WC_Abstract_Order->has_free_item();
Changelog
| Since 2.5.0 | Introduced. |
WC_Abstract_Order::has_free_item() WC Abstract Order::has free item code WC 10.4.3
public function has_free_item() {
foreach ( $this->get_items() as $item ) {
if ( ! $item->get_total() ) {
return true;
}
}
return false;
}