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;
}

One thought on “Making Tax use discounted price

  1. 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;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>