Jump to content

How do I tax the entire total? (Products + Shipping)


Recommended Posts

In prestashop, I can tax the products, and then tax the shipping with one rate. However, for where I am selling (Canada), I need prestashop to apply tax (if applicable) to the entire order, including shipping, not just the products bought. Does anyone know where I could modify the total (or how to), so that the tax (if applicable) taxes the entire order and shipping? (and not just the product total):

i.e. current configuration:

product 1 $10
tax (13%) $1.3

Shipping $10
===========
Total: $21.3


What I would like is:

product 1 $10
Shipping $10
tax (13%) $2.6
===========
Total: $22.6


If anyone knows, it would be greatly appreciated,

Link to comment
Share on other sites

True, and please correct me if I'm wrong, but you can only add a specific tax to the carrier.

For example, if I had three tax rates defined:

Tax Rate 1 - GST: 5%
Tax Rate 2 - PST AND GST: 13%
Tax Rate 3 - HST 13%

Prestashop apply one of those rates to the carrier. For instance, I could apply GST (5%) to the carrier, and all shipments from that carrier would be taxed 5%.

The thing is, I want the tax rate set up so that the tax rate that is dictated by state/zone, so that if you're in the state that has has GST 5%, shipping is taxed 5%, if your in the state that has HST, shipping is taxed 13%, and if you're in a zone that has no tax, well, you're not taxed on shipping at all. Thus the reason I want the tax to be calculated after shipping has been added, and not before.

Link to comment
Share on other sites

I was thinking of doing this in order to work around the above problem:

In classes/cart.php, modifying the line (around lines 745 -747):

// Apply tax
if (isset($carrierTax))
$shipping_cost *= 1 + ($carrierTax / 100);

To:

// Apply tax
if (isset($carrierTax))
$shipping_cost *= 1 + (X / 100);

Where 'X' is the state tax (in my case, the province), so that if carrier tax is selected, instead of using the tax that is defined for the carrier, it just applies the state's selected tax (if it be 5%, 13%, or what have you). That way, the tax on shipping is same as the state's tax.

The issue is, in cart.php, what variable do I use to reference the state tax selected (displayed as 'X' in the above code)? I'm having trouble finding the tax applied to that customer's state to use as that variable.

Link to comment
Share on other sites

  • 1 month later...

I was just working on making this change myself. We need to charge state tax on shipping in Wisconsin.

I find that adding as you said to the following code will not work right:

In classes/cart.php, modifying the line (around lines 745 -747):
// Apply tax if (isset($carrierTax)) $shipping_cost *= 1 + ($carrierTax / 100);


This will cause your shipping charges to just show as being higher. I guess for some that may work fine. But, what I did was change line 633 of classes/Cart.php (At least I think it's around line 633 of version 1.2.5, my Cart.php file has a number of other mods to it)

from:
if ($type == 3) $order_total += $shipping_fees  + $wrapping_fees;


to:

//Get the tax on no product for no tax id, should come back with just state tax if there is one
   if($withTaxes){
       $shippingTax = floatval(Tax::getApplicableTax(0,0));
   }

   //Added state tax on shipping in next line
   if ($type == 3) $order_total += ($shipping_fees * (1 + ($shippingTax / 100))) + $wrapping_fees;



I haven't totally tested it in all cases yet, but it looks like it will work.

Link to comment
Share on other sites

  • 9 months later...

Bumping this thread as I have been dealing with the same issue recently. I do not think the above suggested change is ideal as it does not deal with all cases as some areas in the code grab the shipping total directly instead of via Cart::getOrderTotal(). Moving the location based tax lookup into Cart::getOrderShippingCost() however seems to solve that problem.

Look for the following section in the getOrderShippingCost() method (around line 820):

if ($useTax AND $carrier->id_tax)
       {
           if (!isset(self::$_taxes[$carrier->id_tax]))
               self::$_taxes[$carrier->id_tax] = new Tax(intval($carrier->id_tax));
           $tax = self::$_taxes[$carrier->id_tax];
           if (Validate::isLoadedObject($tax) AND Tax::zoneHasTax(intval($tax->id), intval($id_zone)) AND !Tax::excludeTaxeOption())
               $carrierTax = $tax->rate;
       }



Replace it with:

               $provincialTax=floatval(Tax::getApplicableTax(0,0));
       if ($useTax AND ($carrier->id_tax || $provincialTax>0))
       {
           if($carrier->id_tax)
           {
               if (!isset(self::$_taxes[$carrier->id_tax]))
               {
                   self::$_taxes[$carrier->id_tax] = new Tax(intval($carrier->id_tax));
               }
               $tax = self::$_taxes[$carrier->id_tax];
               if (Validate::isLoadedObject($tax) AND Tax::zoneHasTax(intval($tax->id), intval($id_zone)) AND !Tax::excludeTaxeOption())
               $carrierTax = $tax->rate;
           }
           else
           {
               $carrierTax=$provincialTax;
           }    
       }



This code will use the carrier tax if explicitly set in the admin shipping settings, else it will use whatever tax the cart has set (which will be provincial if relevant).

Cheers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...