/**
* Get the product row subtotal.
*
* Gets the tax etc to avoid rounding issues.
*
* When on the checkout (review order), this will get the subtotal based on the customer's tax rate rather than the base rate
*
* @params object product
* @params int quantity
* @return string formatted price
*/
public function get_product_subtotal($_product, $quantity)
{
global $woocommerce;
$price = $_product->get_price();
$taxable = $_product->is_taxable();
$base_tax_rates = $this->tax->get_shop_base_rate($_product->tax_class);
$tax_rates = $this->tax->get_rates($_product->get_tax_class());
// This will get the base rate unless we're on the checkout page
// Taxable
if ($taxable) {
if ($this->tax_display_cart == 'excl') {
$row_price = $_product->get_price_excluding_tax($quantity);
$product_subtotal = woocommerce_price($row_price);
if ($this->prices_include_tax && $this->tax_total > 0) {
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
}
} else {
$row_price = $_product->get_price_including_tax($quantity);
$product_subtotal = woocommerce_price($row_price);
if (!$this->prices_include_tax && $this->tax_total > 0) {
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
}
}
// Non-taxable
} else {
$row_price = $price * $quantity;
$product_subtotal = woocommerce_price($row_price);
}
return apply_filters('woocommerce_cart_product_subtotal', $product_subtotal, $_product, $quantity, $this);
}