WC_Discounts::sort_by_price( array $a, array $b )

Sort by price.


Description Description


Parameters Parameters

$a

(Required) First element.

$b

(Required) Second element.


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class-wc-discounts.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.