WC_Discounts::get_discounts_by_item( bool $in_cents = false )

Get all discount totals per item.


Description Description


Parameters Parameters

$in_cents

(Optional) Should the totals be returned in cents, or without precision.

Default value: false


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-wc-discounts.php

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

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.