Making Tax use discounted price
Needed to put this somewhere just incase we decide to add it into core.
function calculate_total_tax() {
global $wpdb;
$total = 0;
if($this->total_tax == null && $this->coupons_amount == 0) {
foreach($this->cart_items as $key => $cart_item) {
$total += $cart_item->tax;
}
} elseif($this->coupons_amount == 0) {
$total = $this->subtotal-$this->coupons_amount;
$total = $total /(100) *$wpsc_cart->tax_percentage;
}else{
$total = $this->total_tax;
}
return $total;
}
or if 3.7.6
function calculate_total_tax() {
global $wpdb, $wpsc_cart;
$total = 0;
if(wpsc_tax_isincluded() == false){
if($this->total_tax == null && $this->coupons_amount == null) {
foreach($this->cart_items as $key => $cart_item) {
$total += $cart_item->tax;
}
$this->total_tax = $total;
} elseif($this->coupons_amount == null) {
$total = $this->total_tax;
}else{
//exit('
'.print_r($this,true).'
');
$total = $this->subtotal-$this->coupons_amount;
$total = $total /(100) *$wpsc_cart->tax_percentage;
}
}else{
if($this->total_tax == null) {
foreach($this->cart_items as $key => $cart_item) {
$total += $cart_item->taxable_price/(100+$wpsc_cart->tax_percentage)*$wpsc_cart->tax_percentage;
}
$this->total_tax = $total;
} else {
$total = $this->total_tax;
}
}
return $total;
}
on February 3, 2010
at 12:05 pm
Actually try this:
function calculate_total_tax()
{
global $wpdb,$wpsc_cart;
$total = 0;
if($this->total_tax == null)
{
foreach($this->cart_items as $key => $cart_item)
{
$total += $cart_item->tax;
}
}
else
{
$total = $this->total_tax;
}
// Remove tax from coupon amount
if($this->coupons_amount)
{
$coupon_tax = $this->coupons_amount * ($wpsc_cart->tax_percentage/100);
if($this->total_tax==null)
{
$total=$total-$coupon_tax;
}
}
return $total;
}