WC_Abstract_Order::get_item_subtotal()publicWC 1.0

Get item subtotal - this is the cost before discount.

Метод класса: WC_Abstract_Order{}

Хуки из метода

Возвращает

float.

Использование

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->get_item_subtotal( $item, $inc_tax, $round );
$item(объект) (обязательный)
Item to get total from.
$inc_tax(true|false)
-
По умолчанию: false)
$round(true|false)
-
По умолчанию: true)

Код WC_Abstract_Order::get_item_subtotal() WC 8.7.0

public function get_item_subtotal( $item, $inc_tax = false, $round = true ) {
	$subtotal = 0;

	if ( is_callable( array( $item, 'get_subtotal' ) ) && $item->get_quantity() ) {
		if ( $inc_tax ) {
			$subtotal = ( (float) $item->get_subtotal() + (float) $item->get_subtotal_tax() ) / $item->get_quantity();
		} else {
			$subtotal = ( (float) $item->get_subtotal() ) / $item->get_quantity();
		}

		$subtotal = $round ? NumberUtil::round( $subtotal, wc_get_price_decimals() ) : $subtotal;
	}

	return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round );
}