WC_Discounts::sort_by_price
Sort by price.
Метод класса: WC_Discounts{}
Хуков нет.
Возвращает
int.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->sort_by_price( $a, $b );
- $a(массив) (обязательный)
- First element.
- $b(массив) (обязательный)
- Second element.
Список изменений
| С версии 3.2.0 | Введена. |
Код WC_Discounts::sort_by_price() WC Discounts::sort by price WC 10.8.1
protected function sort_by_price( $a, $b ) {
$price_1 = $a->quantity > 1 ? $a->price / $a->quantity : $a->price;
$price_2 = $b->quantity > 1 ? $b->price / $b->quantity : $b->price;
if ( $price_1 === $price_2 ) {
return 0;
}
return ( $price_1 < $price_2 ) ? 1 : -1;
}