Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Discount Coupons and Tax Calculation

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-19-2004, 10:43 AM
 
mixman mixman is offline
 

Member
  
Join Date: Aug 2003
Posts: 20
 

Default Discount Coupons and Tax Calculation

Can anyone help me modify my discount coupon and tax calculation for xcart ver. 3.4.8

Xcart seems to still base sales tax on the price before the coupon.

For example, a customer makes a $100 purchase and applies a 10% discount coupon. Currently Xcart calculates sales tax based on $100 instead of $90. I would like it calculate the tax on the total after the discount is applied. I have had a few customers notice this and complain that I'm overcharging. They are right! I use Canadian Tax system GST & PST . If anyone knows how to correct this that would be great.

Thanks
Mike
Reply With Quote
  #2  
Old 05-19-2004, 12:16 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

You're best bet is to look at the 2 functions func_calculate_single and func_calculate and see if its doing the tax calculation before the discount

In the version i have it does the discount before the taxes (or atleast the comments say so)


I don't have access to the version of cart that you are using, but if you have trouble, you can e-mail me your func.php and i can take a look.
__________________
Mod King
Reply With Quote
  #3  
Old 05-19-2004, 04:56 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Let's keep this forum for finished mods only please. This is a better post for Order Management or Storefront Management.

That said, I would love to know the answer as well, but hopefully a moderator will move it back once we have modified code to share.
Reply With Quote
  #4  
Old 05-19-2004, 05:21 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

I made an attempt to fix it, and sent it to him for testing.

If it works i'll post the fix.
__________________
Mod King
Reply With Quote
  #5  
Old 05-19-2004, 05:29 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

That would be great.

The idea is try to keep this forum clean and free of requests that should be posted in the other areas dedicated to Q & A. Tested and complete solutions are always welcome.
Reply With Quote
  #6  
Old 05-19-2004, 05:37 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

that is totally understandable, i'll watch before I post next time.


But from what i looked at. It appears that they calculate a taxable total for all 3 types tax, gst, pst then they only subtract the discount from the shipping_total and total instead of those 3 values.

So I added some code to subtract discount and coupon discount from all three of those.

Hopefully it works properly.
__________________
Mod King
Reply With Quote
  #7  
Old 05-19-2004, 05:40 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Should really be an option in the admin. Check boxes to enable various taxes on discounts.

I've suggested it to X-cart before, I hope it makes it into future builds.
Reply With Quote
  #8  
Old 05-19-2004, 05:50 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

I'm really surprised it isn't. It seems logical to not tax the discounted amount.
__________________
Mod King
Reply With Quote
  #9  
Old 05-19-2004, 06:07 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

Here's the fix i did that seemed to work.

I didn't post the whole function, but here is part of it. I am not sure what versions everyone is using, but this is the fix to mixmans

its in ./funch.php
around line 731 for his, in the function func_calculate_single

I put comments in where i added some lines so everyone can see the change.


Code:
# # Deduct discount # $discount_info = func_query_first("select * from $sql_tbl[discounts] where minprice<='$avail_discount_total' $provider_condition and membership='$customer_info[membership]' order by minprice desc"); $discountall_info = func_query_first("select * from $sql_tbl[discounts] where minprice<='$avail_discount_total' $provider_condition and membership='' order by minprice desc"); if ($discount_info["discount_type"]=="absolute" && $avail_discount_total>0) $discount += $discount_info["discount"]; elseif ($discount_info["discount_type"]=="percent") $discount += $avail_discount_total*$discount_info["discount"]/100; elseif ($discountall_info["discount_type"]=="absolute" && $avail_discount_total>0) $discount += $discountall_info["discount"]; elseif ($discountall_info["discount_type"]=="percent") $discount += $avail_discount_total*$discountall_info["discount"]/100; $total = $total-$discount; //mod king change here $total_shipping -= $discount; $total_taxable_gst-=$discount; $total_taxable_pst-=$discount; //end of lines added $total_taxable-=$discount; if ($total_shipping < 0) $total_shipping = 0; # # Deduct discount by discount coupon # $coupon_discount=0; $coupon_total = 0; $coupon_amount = 0; $discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon='$discount_coupon' $provider_condition"); if (($discount_coupon_data["productid"]>0) and (($discount_coupon_data["coupon_type"]=="absolute") or ($discount_coupon_data["coupon_type"]=="percent"))) { foreach($products as $product) { if ($product["productid"] == $discount_coupon_data["productid"]) { $coupon_total += $product["price"]*$product["amount"]; $coupon_amount += $product["amount"]; } } if ($discount_coupon_data["coupon_type"]=="absolute") { $coupon_discount = $coupon_amount*$discount_coupon_data["discount"]; } else { $coupon_discount = $coupon_total*$discount_coupon_data["discount"]/100; } } elseif (($discount_coupon_data["categoryid"]>0) and (($discount_coupon_data["coupon_type"]=="absolute") or ($discount_coupon_data["coupon_type"]=="percent"))) { foreach ($products as $product) { if ($product["categoryid"] == $discount_coupon_data["categoryid"]) { $coupon_total += $product["price"]*$product["amount"]; $coupon_amount += $product["amount"]; } } if ($discount_coupon_data["coupon_type"]=="absolute") { $coupon_discount = $coupon_amount*$discount_coupon_data["discount"]; } else { $coupon_discount = $coupon_total*$discount_coupon_data["discount"]/100; } } else { if ($discount_coupon_data["coupon_type"]=="absolute") $coupon_discount = $discount_coupon_data["discount"]; elseif ($discount_coupon_data["coupon_type"]=="percent") $coupon_discount = $total*$discount_coupon_data["discount"]/100; } if ((!$single_mode) and (($discount_coupon_data["provider"] != $provider_for) or (!$products))) $discount_coupon = ""; $total = $total-$coupon_discount; //mod king change here added these 3 lines $total_taxable_gst-=$coupon_discount; $total_taxable-=$coupon_discount; $total_taxable_pst-=$coupon_discount; //end of change $total_shipping -= $coupon_discount; if ($total_shipping<0) $total_shipping = 0;
__________________
Mod King
Reply With Quote
  #10  
Old 05-19-2004, 06:08 PM
 
mixman mixman is offline
 

Member
  
Join Date: Aug 2003
Posts: 20
 

Default discount coupons and taxes

Hi Mod King,

Thanks for solving the problem. It is calculating everything correctly. Job well done!!!

To adpboss; I got your message and will stick to recommended forums.

Regards,
Mixman
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:33 PM.

   

 
X-Cart forums © 2001-2020