WC_Abstract_Order::get_item_total( object $item, bool $inc_tax = false, bool $round = true )

Calculate item cost – useful for gateways.


Description Description


Parameters Parameters

$item

(Required) Item to get total from.

$inc_tax

(Optional) (default: false).

Default value: false

$round

(Optional) (default: true).

Default value: true


Top ↑

Return Return

(float)


Top ↑

Source Source

File: includes/abstracts/abstract-wc-order.php

	public function get_item_total( $item, $inc_tax = false, $round = true ) {
		$total = 0;

		if ( is_callable( array( $item, 'get_total' ) ) && $item->get_quantity() ) {
			if ( $inc_tax ) {
				$total = ( $item->get_total() + $item->get_total_tax() ) / $item->get_quantity();
			} else {
				$total = floatval( $item->get_total() ) / $item->get_quantity();
			}

			$total = $round ? round( $total, wc_get_price_decimals() ) : $total;
		}

		return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.