WC_Discounts::sort_by_price()
Sort by price.
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. |
WC_Discounts::sort_by_price() WC Discounts::sort by price code WC 9.7.1
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; }