My Zen Cart discounts with different taxes for shipping vs products

Different rates of tax for shipping

This is an uncommon situation, but it may apply to you if you are from British Columbia, Canada.

If you have taxable shipping but the tax rate is different than it is for products, you’ll need to make some code changes. Firstly, be sure your descriptions for shipping taxes include an easily identifiable string such as “on shipping”
Tax Rates in Zen Admin

Then, in the discount module you use, skip over this tax when computing the updated amount of tax.

Here is a block of logic from Quantity Discounts 1.11. (Newer versions may look different.)

       switch ($this->calculate_tax) {
       case 'Standard':
          reset($order->info['tax_groups']);
          while (list($key, $value) = each($order->info['tax_groups']))
          {

             if (strpos($key,"on shipping") !== false) {
                continue;
             }

             $tax_rate = zen_get_tax_rate_from_desc($key);
             if ($tax_rate > 0) {
                $od_amount[$key] = $tod_amount = round((($od_amount['total'] * $tax_rate)) /100, 2) ;
                $od_amount['tax'] += $tod_amount;
             }
          }
          break;

Here is a block of logic from Big Chooser 1.2.16. (Newer versions may look different.)

       switch ($this->calculate_tax) {
       case 'Standard':
          reset($order->info['tax_groups']);
          $taxGroups = array_keys($order->info['tax_groups']);
          foreach ($taxGroups as $key )
          {

             if (strpos($key,"on shipping") !== false) {
                continue;
             }

             $tax_rate = zen_get_tax_rate_from_desc($key);
             if ($tax_rate > 0) {
                $od_amount[$key] = $tod_amount = round((($taxable_amount  * $tax_rate)) /100, 2) ;
                $od_amount['tax'] += $tod_amount;
             }
          }
          break;