Forums / Currencies & Sales Taxes, VAT, GST, etc. / Speicals and Sales Tax Not Included

Speicals and Sales Tax Not Included

Views: 3,824

Results 1 to 20 of 22
5 Jul 2015, 3:27 AM
#1
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Speicals and Sales Tax Not Included

Hello

I have a little problem with taxes not being included in sales and specials tags. The price is calculated correctly -- it's just the visual that is showing as wrong.

Example:

Product price: Was $50 now $40
Save: $9.09 (this should read $10)

The problem is on all pages where a special or sale price is shown.

All prices are calculated properly, so there's no problem when going through checkout, etc. It's just very confusing when a client sees a figure that doesn't add up.

Any ideas on how I could correct this please?

Thanks.

5 Jul 2015, 6:18 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

MortalWombat:

Hello

I have a little problem with taxes not being included in sales and specials tags. The price is calculated correctly -- it's just the visual that is showing as wrong.

Example:

Product price: Was $50 now $40
Save: $9.09 (this should read $10)

The problem is on all pages where a special or sale price is shown.

All prices are calculated properly, so there's no problem when going through checkout, etc. It's just very confusing when a client sees a figure that doesn't add up.

Any ideas on how I could correct this please?

Thanks.

How does 9.09 come into play? There seems to be a lot missing from the description of the setup including an example of this issue. What other plugin(s) are installed?

Does the same issue appear when temporarily switching to the default template?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

5 Jul 2015, 6:45 AM
#3
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

mc12345678:

How does 9.09 come into play? There seems to be a lot missing from the description of the setup including an example of this issue. What other plugin(s) are installed?

Does the same issue appear when temporarily switching to the default template?

Apologies for not being entirely clear.

$9.09 is $10 missing the 10% tax component (sorry, I forgot to mention the tax amount). So the product price is $50 with a $10 reduction, making it $40. The 'Save $x.xx' part should show 'Save $10', but it instead shows 'Save $9.09'. I've attached an image as an example. $11.82 should be $13 (11.82 + 10% = 13).

After looking into the problem more since posting this thread, I've discovered that the issue stems from the custom template I have installed, which has altered the framework of pricing functions. I can't remove the pricing alterations the template has made, as the template is based on the alterations. Following is the functions snippet:

// Price Functions Improvement
function pt_get_discount_amount($products_id) {
  global $db, $currencies;

  $show_sale_discount = '';

  $display_normal_price = zen_get_products_base_price($products_id);
  $display_special_price = zen_get_products_special_price($products_id, true);
  $display_sale_price = zen_get_products_special_price($products_id, false);

  if (SHOW_SALE_DISCOUNT_STATUS == '1' and ($display_special_price != 0 or $display_sale_price != 0)) {
    if ($display_sale_price) {
      if (SHOW_SALE_DISCOUNT == 1) {
        if ($display_normal_price != 0) {
          $show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
        } else {
          $show_discount_amount = '';
        }
        $show_sale_discount = $show_discount_amount . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;

      } else {
        $show_sale_discount = $currencies->display_price(($display_normal_price - $display_sale_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
      }
    } else {
      if (SHOW_SALE_DISCOUNT == 1) {
        $show_sale_discount = number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS) . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;
      } else {
        $show_sale_discount = $currencies->display_price(($display_normal_price - $display_special_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
      }
    }
  }

  return $show_sale_discount;

}

I've compared the above coding to what's in functions_prices.php, but I can't work out what needs to be altered/added/removed. Normally I would be bringing this up with the template author, and have sent an email for his help, but due to personal problems, he is unavailable for the time.

5 Jul 2015, 7:16 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

Is this one marked as a sale or a special? There is actually ZC code that does all this, but if it is necessary to independently do these calculations, then let's see what is needed...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

5 Jul 2015, 7:39 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

Is there a reason that you have SHOW_SALE_DISCOUNT not set to 1?
That appears in the code to be the reason that tax is factored into the price.

If there is a reason, then yes would need to change the calculation(s).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jul 2015, 3:25 AM
#6
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

mc12345678:

Is this one marked as a sale or a special? There is actually ZC code that does all this, but if it is necessary to independently do these calculations, then let's see what is needed...

This is a sale item. However, the problem applies to both sales and specials.

I am aware that Zen Cart has its own code for pricing, but as I said, this piece of code is a part of the template I'm using, and it has been coded through the store.

mc12345678:

Is there a reason that you have SHOW_SALE_DISCOUNT not set to 1?
That appears in the code to be the reason that tax is factored into the price.

If there is a reason, then yes would need to change the calculation(s).

I actually don't know anything about the whys of the code, as I didn't personally write it. As there are a few instances of SHOW_SALE_DISCOUNT, I assume you're referring to the third line, since it's the only one without a value... Unfortunately, entering '1' there only adds a sale tag with 'Save 1' to items that are not on sale and makes no difference to the sale items.

6 Jul 2015, 5:28 AM
#7
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

MortalWombat:

This is a sale item. However, the problem applies to both sales and specials.

I am aware that Zen Cart has its own code for pricing, but as I said, this piece of code is a part of the template I'm using, and it has been coded through the store.
what template are you using btw?

I actually don't know anything about the whys of the code, as I didn't personally write it. As there are a few instances of SHOW_SALE_DISCOUNT, I assume you're referring to the third line, since it's the only one without a value... Unfortunately, entering '1' there only adds a sale tag with 'Save 1' to items that are not on sale and makes no difference to the sale items.

I'm not sure, but I don't think he was asking you to change the code there. I interpreted it to mean do you ever set SHOW_SALE_DISCOUNT to 2. You set this in the configuration under product information. If it is 1 then it means you want to show the sale as a %off. If it is 2, you want to show it as the amount off.

You also have two tax settings in the configuration. One asks if you want to display prices with tax, the other if you want to display prices in the admin with tax. What do you have these set to? Those two are under configuration, my store.

Linda

6 Jul 2015, 5:45 AM
#8
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

lruskauff:

what template are you using btw?

The template is called Morphling. It's a premium theme available on ThemeForest (however, due to what I mentioned earlier, the item is temporarily unavailable).

lruskauff:

I'm not sure, but I don't think he was asking you to change the code there. I interpreted it to mean do you ever set SHOW_SALE_DISCOUNT to 2. You set this in the configuration under product information. If it is 1 then it means you want to show the sale as a %off. If it is 2, you want to show it as the amount off.

You also have two tax settings in the configuration. One asks if you want to display prices with tax, the other if you want to display prices in the admin with tax. What do you have these set to? Those two are under configuration, my store.

Linda

Ah, OK -- I hadn't read it like that, but that perhaps makes more sense...

The product info configuration option is always set to 2 (amount off) in this store, and the two tax options are both set to true (display prices with tax included).

6 Jul 2015, 6:12 AM
#9
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

MortalWombat:

The template is called Morphling. It's a premium theme available on ThemeForest (however, due to what I mentioned earlier, the item is temporarily unavailable).
I just asked because usually a template will change the way an item displays but not a way an item is computed.

Ah, OK -- I hadn't read it like that, but that perhaps makes more sense...

The product info configuration option is always set to 2 (amount off) in this store, and the two tax options are both set to true (display prices with tax included).
Ok. So on your picture below, it has a price of: 32.50. Is that the price WITH or WITHOUT tax included? It should be the price with tax, because of the option you set above.

Linda

6 Jul 2015, 6:35 AM
#10
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

lruskauff:

I just asked because usually a template will change the way an item displays but not a way an item is computed.

Yes, I know... I have no idea why the author altered the way prices are computed, and of course was not aware of the change until I began the template installation.

lruskauff:

Ok. So on your picture below, it has a price of: 32.50. Is that the price WITH or WITHOUT tax included? It should be the price with tax, because of the option you set above.

Linda

All prices in the store, including the two lower ones shown in the attached screenshot ($32.50 and $19.50), are tax INclusive -- that is, EXCEPT for the price showing the amount saved ($11.82), which is EXclusive of tax.

6 Jul 2015, 6:44 AM
#11
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

MortalWombat:

Yes, I know... I have no idea why the author altered the way prices are computed, and of course was not aware of the change until I began the template installation.
Well, the more I thought about this one, the more it could be likely. He may have built in other modules, who knows.

All prices in the store, including the two lower ones shown in the attached screenshot ($32.50 and $19.50), are tax INclusive -- that is, EXCEPT for the price showing the amount saved ($11.82), which is EXclusive of tax.
[/quote]
So:
Price w tax: 32.50
Sale price w tax: 19.50

Did you put the sale price in by entering a % or an actual $ amount
What is the tax rate on that item?
What is the original price on the item?

It may be a different piece of code we need to look at.

6 Jul 2015, 6:48 AM
#12
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

Just checking, did you try switching back to the classic template, do you get the same results or the correct results?

6 Jul 2015, 6:57 AM
#13
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

lruskauff:

Well, the more I thought about this one, the more it could be likely. He may have built in other modules, who knows.

True.

lruskauff:

So:
Price w tax: 32.50 Correct
Sale price w tax: 19.50 Correct

Did you put the sale price in by entering a % or an actual $ amount A percentage amount (40% on this item) is entered on sale items. An actual amount is used for specials. This is actually an upgrade of a ZC installation I've been running for ~10 years, so it's all running as it should on the current live site.
What is the tax rate on that item? Tax rate is 10%
What is the original price on the item? Original price on the item in the screenshot is $32.50. Discount entered on sales maker is 40%, bringing the item down to $19.50.

It may be a different piece of code we need to look at.

lruskauff:

Just checking, did you try switching back to the classic template, do you get the same results or the correct results?

Switching back to the classic template computes the sales and specials prices correctly, so it is definitely the template alterations doing it.

6 Jul 2015, 7:07 AM
#14
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

$32.50 price with tax. What is the price without the tax?

6 Jul 2015, 7:12 AM
#15
mortalwombat avatar

mortalwombat

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
131
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

lruskauff:

$32.50 price with tax. What is the price without the tax?

$32.50 without tax is $29.55.

6 Jul 2015, 7:13 AM
#16
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

Probably because as far as sales go, the default admin entry doesn't deal/work with the show prices with taxes aspect... See the correction/adjustment posted here: https://www.zen-cart.com/showthread.php?217521-Bug-price-manager-adds-Tax-to-the-promotional-price!-Help-needed&p=1284702#post1284702

I was working on a way to show the two prices separately like what is done on the product entry page, but...

As for the remaining "issue", yes, price difference is shown with tax being added to the prices as if the price(s) were not "entered properly"... By properly meaning that in such a way as to show on the screen with the tax already considered... As a result the difference between the two prices should be as requested...

I have been able with a blank store have a product that displays with $50 for the normal price, applied a sale to give $40, have a 10% tax, and to show the store and admin side taxes and in the end get the desired result..

may need to modify the code so that it doesn't add tax to the differences..

Haven't tried to see what it takes to correct the way that the discount is calculated and why it is done differently than the ZC standard method. Anyways, the above code is some sort of special discount calculation code instead of using the values generated by the core function(s).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jul 2015, 7:19 AM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

45.4545 - $50 product with 10% sales tax applied, price entered as including tax,
36.3645 - $40 entered as a special price. Difference between these two values when tax is included in the prices is $10. Turn tax off, then things get weird..

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jul 2015, 7:48 AM
#18
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

Here is the code you supplied:

PHP Code:
// Price Functions Improvement
function pt_get_discount_amount($products_id) {
global $db, $currencies;

$show_sale_discount = '';

$display_normal_price = zen_get_products_base_price($products_id);
$display_special_price = zen_get_products_special_price($products_id, true);
$display_sale_price = zen_get_products_special_price($products_id, false);

if (SHOW_SALE_DISCOUNT_STATUS == '1' and ($display_special_price != 0 or $display_sale_price != 0)) {
if ($display_sale_price) { IF THIS IS A SALE AND NOT A SPECIAL
if (SHOW_SALE_DISCOUNT == 1) { IF SHOW AS A PERCENT IS SET
if ($display_normal_price != 0) {
$show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
} else {
$show_discount_amount = '';
}
$show_sale_discount = $show_discount_amount . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;

  } else {                          IF SHOW AS AN AMOUNT IS SET
    $show_sale_discount = $currencies->display_price(($display_normal_price - $display_sale_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
  }
} else {  (IF THIS IS A SPECIAL AND NOT A SALE)
  if (SHOW_SALE_DISCOUNT == 1) {    IF SHOW AS A % IS SET
    $show_sale_discount = number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS) . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;
  } else {                          IF SHOW AS AN AMOUNT IS SET 
    $show_sale_discount = $currencies->display_price(($display_normal_price - $display_special_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
  }
}

}

return $show_sale_discount;

Hello again
I put the logic of your code in blue. With your example, the parts after "if SHOW AS AN AMOUNT IS SET" are the parts that compute the sales discount and returns it as a string with other crap (like the % sign or decimals). Except, it looks the same as the code in the normal functions_prices.php. (did you compare it against the code in functions_prices.php with an unmodified zencart? I'm very tired so maybe I'm not seeing it, BUT the only difference I see is that they have a class assigned which prob formats the string. So I'm stumped.

I would look at the code where this is returned and see if any more modifications are done to it before it is displayed.

Question: Did you test it with % to see if it gives the correct %? I would do that next.

Also, are you running version 1.54 of Zencart?

I'm sure someone will be back to help before I wake up and I know I will be anxious to see what the heck is wrong. But if not, I'll help you look some more. Sorry I'm no expert.

Linda

6 Jul 2015, 11:48 AM
#19
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Speicals and Sales Tax Not Included

OP claimed to be running 1.5.4 as seen on the page/tab title for this thread (can see it through my browser, but not necessarly on this page.

So like lruskauff, I was getting tired. But I see now wht was missing, ut haven't yet figured out how to generate it.

The variable $product_check is used, but never declared/calculated... Shouldn't be hard to get it sorted, but basically. Need to return the tax class(es) for the product in question before using the cost comparison. That way the 10% tax would get factored into the difference between the two prices whch each are showing to be taxed (requires calculaton to get there), but when resolving the difference between the two the tax is not yet applied.

I thought I remembered seeing that the ZC version of the function has a large SQL statement to factor for all tax types, the session information, etc... And that (the SQL execute result) needs to be set to the variable $product_check

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jul 2015, 5:19 PM
#20
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Speicals and Sales Tax Not Included

The variable $product_check is used, but never declared/calculated... Shouldn't be hard to get it sorted, but basically. Need to return the tax class(es) for the product in question before using the cost comparison. That way the 10% tax would get factored into the difference between the two prices which each are showing to be taxed (requires calculaton to get there), but when resolving the difference between the two the tax is not yet applied.

I thought I remembered seeing that the ZC version of the function has a large SQL statement to factor for all tax types, the session information, etc... And that (the SQL execute result) needs to be set to the variable $product_check[/QUOTE]

[/quote]
To me, it looks like his function, pt_get_discount_amount, was taken from the middle of Zencarts zen_get_products_display_price. And that has the following before the code:

   $product_check = $db->Execute("select products_tax_class_id, products_price, products_priced_by_attribute, product_is_free, product_is_call, products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'" . " limit 1");

    // no prices on Document General
    if ($product_check->fields['products_type'] == 3) {
      return '';
    }

So if this function only needs the tax class id, it could be shortened to:

 $product_check = $db->Execute("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'" . " limit 1");

I'm still looking for the SQL version you mentioned above but it really depends on whether I am guessing correctly as to what this function should do. So maybe the best advice would be is to chose a new template?