WC_Abstract_Order::get_subtotal_to_display()
Gets subtotal - subtotal is shown before discounts, but with localised taxes.
Method of the class: WC_Abstract_Order{}
Hooks from the method
Return
String
.
Usage
$WC_Abstract_Order = new WC_Abstract_Order(); $WC_Abstract_Order->get_subtotal_to_display( $compound, $tax_display );
- $compound(true|false)
- -
Default: false) - $tax_display(string)
- -
Default: tax_display_cart value)
WC_Abstract_Order::get_subtotal_to_display() WC Abstract Order::get subtotal to display code WC 9.7.1
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 ); }