WordPress at Your Fingertips
function is not described

WC_Discounts::sort_by_price() protected WC 3.2.0

Sort by price.

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

No Hooks.

Return

Int.

Usage

// protected - for code of main (parent) or child class
$result = $this->sort_by_price( $a, $b );
$a(array) (required)
First element.
$b(array) (required)
Second element.

Changelog

Since 3.2.0 Introduced.

Code of WC_Discounts::sort_by_price() WC 5.6.0

protected function sort_by_price( $a, $b ) {
	$price_1 = $a->price * $a->quantity;
	$price_2 = $b->price * $b->quantity;
	if ( $price_1 === $price_2 ) {
		return 0;
	}
	return ( $price_1 < $price_2 ) ? 1 : -1;
}