WordPress at Your Fingertips
function is not described

WC_Abstract_Order::has_free_item() public WC 2.5.0

Returns true if the order contains a free product.

{} It's a method of the class: WC_Abstract_Order{}

No Hooks.

Return

true|false.

Usage

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->has_free_item();

Changelog

Since 2.5.0 Introduced.

Code of WC_Abstract_Order::has_free_item() WC 5.8.0

public function has_free_item() {
	foreach ( $this->get_items() as $item ) {
		if ( ! $item->get_total() ) {
			return true;
		}
	}
	return false;
}