WC_Discounts::get_discounts_by_item
Get all discount totals per item.
Метод класса: WC_Discounts{}
Хуков нет.
Возвращает
Массив.
Использование
$WC_Discounts = new WC_Discounts(); $WC_Discounts->get_discounts_by_item( $in_cents );
- $in_cents(true|false)
- Should the totals be returned in cents, or without precision.
По умолчанию:false
Список изменений
| С версии 3.2.0 | Введена. |
Код WC_Discounts::get_discounts_by_item() WC Discounts::get discounts by item WC 10.8.1
public function get_discounts_by_item( $in_cents = false ) {
$discounts = $this->discounts;
$item_discount_totals = (array) array_shift( $discounts );
foreach ( $discounts as $item_discounts ) {
foreach ( $item_discounts as $item_key => $item_discount ) {
$item_discount_totals[ $item_key ] += $item_discount;
}
}
return $in_cents ? $item_discount_totals : wc_remove_number_precision_deep( $item_discount_totals );
}