Zen Cart Logo
Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Coupon tax recalculation wierdness.

Coupon tax recalculation wierdness.

Locked

Views: 1,735

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
29 Mar 2007, 2:12 PM
#1
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Coupon tax recalculation wierdness.

I've been working for a few days trying to get the coupon module in 1.3.0 (I know its old, but the client won't pay to upgrade the system) In any case the coupon module wouldn't adjust the tax values. It would calculate the tax discount that was supposed to be applied based on the value of the coupon and would store it in $od_amount as it should but it simply would not apply the discount to the tax total. After spending countless hours looking at different objects and how they were interacting, I noticed the following:

if ( $od_amount['total'] > 0 ){
        while ( list($key, $value) = each($order->info['tax_groups']) ) {
        $tax_rate = zen_get_tax_rate_from_desc($key);
        if ($od_amount[$key]) {
          $order->info['tax_groups'][$key] -= $od_amount[$key];
          $order->info['total'] -=  $od_amount[$key];
         }
      }

this should have done exactly what I wanted, except it wasn't. The while loop wasn't running at all. It seems that for some reason the pointer in the $order->info['tax_groups'] array was at the end of the array. In order to get it working I had to reset($order->info['total']) back to the starting point. So that the while loop would run.
The above code block then looks like:

if ( $od_amount['total'] > 0 ){
        reset($order->info['tax_groups']);
        while ( list($key, $value) = each($order->info['tax_groups']) ) {
        $tax_rate = zen_get_tax_rate_from_desc($key);
        if ($od_amount[$key]) {
          $order->info['tax_groups'][$key] -= $od_amount[$key];
          $order->info['total'] -=  $od_amount[$key];
         }
      }

So I hope this is of some help to someone, and I hope that this problem has been fixed in the later versions. If not this will do it.

30 Mar 2007, 8:48 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Coupon tax recalculation wierdness.

There have been a ton of fixes in this area in more recent versions. Are you billing him for the "countless hours" you're spending working on things that have already been fixed in later versions? I would think this would have paid for the upgrade several times over.

Scott

1 Apr 2007, 7:10 PM
#3
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Re: Coupon tax recalculation wierdness.

well countless this time = 3hrs. I agree that it would probably be beneficial to just upgrade but what I say fell on deaf ears this time. But I'm glad to hear that this has been fixed in future versions. :)