WC_Abstract_Order::get_subtotal_to_display()publicWC 1.0

Gets subtotal - subtotal is shown before discounts, but with localised taxes.

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

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

Возвращает

Строку.

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

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->get_subtotal_to_display( $compound, $tax_display );
$compound(true|false)
-
По умолчанию: false)
$tax_display(строка)
-
По умолчанию: tax_display_cart value)

Код WC_Abstract_Order::get_subtotal_to_display() WC 8.7.0

public function get_subtotal_to_display( $compound = false, $tax_display = '' ) {
	$tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' );
	$subtotal    = (float) $this->get_cart_subtotal_for_order();

	if ( ! $compound ) {

		if ( 'incl' === $tax_display ) {
			$subtotal_taxes = 0;
			foreach ( $this->get_items() as $item ) {
				$subtotal_taxes += self::round_line_tax( (float) $item->get_subtotal_tax(), false );
			}
			$subtotal += wc_round_tax_total( $subtotal_taxes );
		}

		$subtotal = wc_price( $subtotal, array( 'currency' => $this->get_currency() ) );

		if ( 'excl' === $tax_display && $this->get_prices_include_tax() && wc_tax_enabled() ) {
			$subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
		}
	} else {
		if ( 'incl' === $tax_display ) {
			return '';
		}

		// Add Shipping Costs.
		$subtotal += (float) $this->get_shipping_total();

		// Remove non-compound taxes.
		foreach ( $this->get_taxes() as $tax ) {
			if ( $tax->is_compound() ) {
				continue;
			}
			$subtotal = $subtotal + (float) $tax->get_tax_total() + (float) $tax->get_shipping_tax_total();
		}

		// Remove discounts.
		$subtotal = $subtotal - (float) $this->get_total_discount();
		$subtotal = wc_price( $subtotal, array( 'currency' => $this->get_currency() ) );
	}

	return apply_filters( 'woocommerce_order_subtotal_to_display', $subtotal, $compound, $this );
}