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.
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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?
1 Attachment(s)
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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:
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 (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.
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...
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).
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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?
Quote:
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
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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).
Quote:
Originally Posted by
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).
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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.
Quote:
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
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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.
Quote:
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.
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?
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Re: Speicals and Sales Tax Not Included
$32.50 price with tax. What is the price without the tax?
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
lruskauff
$32.50 price with tax. What is the price without the tax?
$32.50 without tax is $29.55.
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....02#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).
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..
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
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
Re: Speicals and Sales Tax Not Included
Quote:
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:
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:
Code:
$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?
Re: Speicals and Sales Tax Not Included
Quote:
Originally Posted by
lruskauff
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]
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:
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:
Code:
$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?[/QUOTE]
Yup the second one should do, my confusion earlier was from looking at. Closely similar query in the function_taxes.php file. That was where tax groups or something were added and then given a name. Anyways, with the above query executed inside that function the display of differences between two prices should now come out correctly in this modified template that was developed by someone currently unavailable for what may be personal reasons...
Hopefully can feedback that information so the next poor soul doesn't have to get it fixed either.
1 Attachment(s)
Re: Speicals and Sales Tax Not Included
I'm very sorry to have left you in the lurch all week. I injured myself and was unable to access a computer, BUT...
Thank you SO much, guys! That snippet of code has included the tax on the specials tags (I have included a screenshot as evidence :D)