Jump to content

[SOLVED] Tax applying to original price instead of sale price


Recommended Posts

I am running into an issue where my state tax is applying to the regular price of an item instead of the discounted, sale price.

For example:
Product "A" is regularly $25.
It is on sale for $20, and displays in the store as such.
State tax is 7.75%.
When Product "A" is added to the cart the tax added is $1.94 (7.75% of $25).

Any suggestions?

Link to comment
Share on other sites

I am completely stumped on this. I've dug around in shopping-cart.tpl which is where the tax seems to be assigned, but I can't figure out which values might need to be changed. I also looked around in Product.php to check out the convertprice function which is called by shopping-cart.tpl. I have no idea what would need to be changed, and I would sincerely appreciate any advice.

Link to comment
Share on other sites

Assuming you are using PS 1.2.*

The taxes get calculated in /classes/Product.php in the function "public static function getPriceStatic()"

As you can see in the code below, taxes get applied right after the price is retrieved from the database (I don't know why it's done that way, it also make the attribute price impact to be POST tax which is very odd)

       $price = $result['price'];

               <!-- START OF TAX PART -->
       // Exclude tax
       $tax = floatval(Tax::getApplicableTax(intval($result['id_tax']), floatval($result['rate'])));
       if ($forceAssociatedTax)
           $tax = floatval($result['rate']);
       if (Tax::excludeTaxeOption() OR !$tax)
           $usetax = false;
       if ($usetax)
           $price *= (1 + ($tax / 100));
               <!-- END OF TAX PART -->

       // Attribute price
       $attribute_price = $usetax ? $result['attribute_price'] : ($result['attribute_price'] / (1 + (($tax ? $tax : $result['rate']) / 100)));
       if (isset($result['attribute_price']))
           $price += $attribute_price;
       $reduc = self::getReductionValue($result['reduction_price'], $result['reduction_percent'], $result['reduction_from'], $result['reduction_to'],
               $price, $usetax, floatval($result['rate']));

       // Only reduction
       if ($only_reduc)
           return $reduc;

       // Reduction
       if ($usereduc)
           $price -= $reduc;

       // Quantity discount
       if ($quantity > 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $quantity)))
           $price -= QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value);

       // Group reduction
       if ($id_customer)
           $price *= ((100 - Group::getReduction($id_customer))/100);



if you move the tax part to the bottom of this code, than it should be calculated after all the reductions, price impact etc.. get added (or reduced) from the price.

Link to comment
Share on other sites

  • 1 month later...
Thank you! Just caught that error after having the site live for a month. Tomerg, I don't think that's the first issue you've helped me solve in the past two months, really appreciate the hellp!


My pleasure.

Feel free to check out my shop and see if there are any modules you like ;)
Link to comment
Share on other sites

  • 2 weeks later...

Hi am getting following error in server error logs:
Undefined variable: tax in /var/www/vhosts/thermometer.co.uk/httpdocs/classes/Product.php on line 1247.

Line 2247 is :
$attribute_price = $usetax ? $result['attribute_price'] : ($result['attribute_price'] / (1 + (($tax ? $tax : $result['rate']) / 100)));

Any ideas why this is - have moved tax code to the bottom as in example above? Have attached Product.php class

Thanks
Baz

Product.php

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...