Jump to content
tdr170

Specific Price - Tax Included ?

Recommended Posts

I am adding a product to my shop that will be a special offer when I go to prices I see a note that stats if set to "amount" - tax is included.

Why is this I want to reduce by an amount not a percentage but it includes tax in the price and then tax is applied to the cart when a product is added.

Is there a way to change this as I can not seem to find one all customer groups are set to tax excluded and I don't want the tax to be part of the price.

Share this post


Link to post
Share on other sites

I did test it and it adds tax to the price, I have a t-shirt on sale, was $15 reduced by amount $3 so now its $12 however when you add to cart it's S12.20 and 85 cents in tax is added for a total of $13.05

If I do a 20% discount which will also be $12 now when I add to cart it stays at $12, 84 cents in tax for a total of $12.84.

 

So it is adding tax, but not to the price but to the $3 dollar reduction even stranger is that 7% of 3 is .21 not .20 ???

 

Very Odd Behavior.

 

Other then this the shop is fine adds tax where it should and not here it should not and tax is always correct.

Edited by tdr170 (see edit history)

Share this post


Link to post
Share on other sites

Somehow i'm sure there is a simple true, false statement in one of the php or tpl files just as of yet I have not found it.

This is one that I will not put alot into as the % works just fine.

Share this post


Link to post
Share on other sites

:-) That's what I feel like doing!! Except I am also using a 'combination' dropdown that modifies the price and the % discount is discounting that too, which I do not want.

Share this post


Link to post
Share on other sites

I found a way to do this specific to my needs and want to share in case it helps anyone else. Tested on version 1.4.7. If anyone knows of a more efficient way, please let me know!

 

This is for developers who want to use the specific price functionality,live in a country where tax only needs to be calculated on the reduced price, and cannot use the percentage based discount because it affects price impacts in product combinations.

 

1. Add a new specific price. Then simply enter your desired sale price (pre tax, of course) into the "Product Price" field. Don't use the percentage or amount price reduction.

 

2. Drop the 2 attached files into your /override folder:

 

Product.php --> /override/classes Product.php

ProductController --> /override/controllers ProductController.php

 

3. Add these lines somewhere in your product.tpl to show the original price:

 

{if $product->specificPrice AND $originalPrice > $productPrice}
 <p id="old_price">Original Price:{convertPrice price=$originalPrice}</p>
 {/if}

  • Like 2

Share this post


Link to post
Share on other sites

You are a genius!!! That bit of code you put together has saved my hide. I've been struggling with this for weeks.

Share this post


Link to post
Share on other sites

Do you happen to know if there's a way to have the Sale Price override any combination-specific prices? I have the following scenario: I have set up a sale on a specific combination and this combination also has a combination-specific increase of $10.00. However, When I set a sale price using your method above it replaces the original price instead of reducing it by an entered amount (like it would do if I used the "amount" method). So my final sale price is still showing the $10.00 combination-specific increase. In the product page - when I'm running a sale, I don't what it to include and combination-specific increase or decreases. Do you know of anyway of doing this?

 

Thanks

Share this post


Link to post
Share on other sites

The easiest way would likely be to set the attribute price to 0 when the specific price variable is set.

 

I can't verify as I don't have a PS development environment setup but it might be in the foreach loop around line 240 of ProductController.php:

 

$combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);

 

I am thinking at the bottom of this loop you can do a simple IF statement to see if the specific price variable is set. If true, then something like this may work:

 

$combinations[$row['id_product_attribute']]['price'] = 0;

Share this post


Link to post
Share on other sites

hmmm.....ok. I've coded in a few languages but this one is new to me so I have a couple of questions if you don't mind. I get the idea of adding a if to check if there's a value in the price for this specific combination, but I also need to check if this combination is On Sale. I've been looking through to find a routine that checks for sales prices added to a combination, but I can't find one. Don't suppose you know how to check it a combination is on sale, by any chance?

 

Thanks

Share this post


Link to post
Share on other sites

Aren't you putting the item on sale by using the Specific Price functionality? Or are you putting something on sale using the "On Sale" checkbox in the admin?

Share this post


Link to post
Share on other sites

I'm applying the sale using the specific price and the On Sale. Do you think this is creating a problem?

 

Btw: for some reason, when I use the overrides you provided above the tax rate that my customers are being charge includes only the global rate of 5%. The additional - per province rules - don't seem to be applied. Do you have any idea what might be causing that? It works perfectly other than that.

 

Thanks again.

Share this post


Link to post
Share on other sites

Ignore the last bit about the tax rate. I wasn't logged in with a set address and that's why it was only applying the country-wide tax rate.

Share this post


Link to post
Share on other sites

It won't be an issue using those two variables together. The specific price should be set in this object:

 

$product->specificPrice

 

If you disable those overrides do the per province tax rules function? I've checked through the code and nothing modifies tax rules that I could see. Try this first to verify this is the issue.

Share this post


Link to post
Share on other sites

gOnzo, we're having the same problem as the OP in this thread. However, we're using PS 1.5.2 and I see your modified file attachments are for 1.4.7.

 

Do you (or does anyone) know if those modifications are available for 1.5.2 anywhere. We're in the U.S. and tax is only charged on the final price of a product, and we really need to be able to use amount discounts as well as percent. It would be nice if there were an option in the software for this.

 

Thanks...

Share this post


Link to post
Share on other sites

@CodeDog if it doesn't work in 1.5.2 it wouldn't take much to bring it up to speed.

 

Product.php - this file only contains 1 function to get the original price from the DB

ProductController.php - I believe I've only added one line of code (line 152) as per the code comment I left. I copied everything from the core file ProductController.php. So for 1.5.2 simply see if the structure is similiar (and do the same) or search for the smarty assignment that existed in the version I was using.

 

Then, modify the template similar to what I've done in my version.

 

If you need more help PM me. I don't have a development version of 1.5.2 running to test out.

Share this post


Link to post
Share on other sites

Thanks for the info, g0nzo, appreciate it. I'll download the files tonight and see what I can do. Sounds like it shouldn't be too bad...

Share this post


Link to post
Share on other sites

g0nzo, just wanted to say thanks again for the help, and let you know in this instance it isn't going to be as easy for me because I found tonight that these files were replaced when some 3rd party modules were installed. Large files with obfuscated code, so it's going to be more difficult, but your code should still help with the process.

 

Appreciate it...

Share this post


Link to post
Share on other sites

@CodeDog, any luck? If not, I might have time to look at this tonight with a fresh install of 1.5.3.

Share this post


Link to post
Share on other sites

Not yet, g0nzo. I was about to dig into it when I saw PS 1.5.3 announced. Right now we're trying to decide what to do about upgrading. I've made quite a few changes/fixes in the core 1.5.2 install, so I'm looking to see what in the ~400 fixes/changes in 1.5.3 are related to my issues. And how the 3rd party modules might be affected.

 

A month ago I wouldn't have thought about upgrading after the changes I've made, but I'm a little more comfortable with the PS system at this point so I'm considering it. Have to set up a test shop with 1.5.3 and check it out first. I'll let you know what I come up with...

Share this post


Link to post
Share on other sites

g0nzo, sorry about being so late getting back here, but have been tied up with a bunch of things, including the upgrade to 1.5.3. Still no fix for this, but I'm going to start a new thread for it...

Share this post


Link to post
Share on other sites

Same question here as CodeDog: how do I change this in 1.5.2?

 

I've got a product for sale at 769€ (original price 919€ so a reduction of 150€) but the price shown is 806,40€. When added to the shopping cart, the price is correct and is 769€.

 

For now I can use a percentage, but I have to use 4 decimals to get the right price: 14.3062% instead of 150€. To show this kind of reduction to clients is very strange.

post-418676-0-33219500-1359713469_thumb.png

Share this post


Link to post
Share on other sites

Gents, I just installed a fresh copy of 1.5.3.1 - My solution will work with some minor tweaks. You can PM me if you want me to fix your specific install. It still depends on using the 'Fixed Price' rather than a % or amount based discount.

 

@CodeDog - The code you need to modify is still in the same file; it is not buried in third party modules as you previously wrote.

Share this post


Link to post
Share on other sites

Hi g0nzo, been a while.

 

I still don't have this fixed yet, and it's the last thing I need to get done in the store.

 

@CodeDog - The code you need to modify is still in the same file; it is not buried in third party modules as you previously wrote.

 

The "Product.php" file you have available for download earlier in the thread is 297 bytes, however my "Products.php" is 9k and obfuscated code. Inserted by a third party module. I can't replace the file without losing the functionality of the module, so it would have to be edited.

 

Our percentage discount works fine, it's just the fixed amount that causes the problem. It's still hard to believe that there are no U.S. stores having this problem, or at least enough stores to cause PrestaShop to address the issue. I've seen numerous entries in the bug tracker over the last 2-3 years where the developers keep saying this has been (or will be) resolved through an option.

 

Don't know...

Share this post


Link to post
Share on other sites

Hey CodeDog.

 

You need to create the "Product.php" file because its going to extend another class. It would be created in override/classes. Your "Products.php" file doesn't need to be touched and is not related to this.

Share this post


Link to post
Share on other sites

Hi g0nzo,

 

I think we may be miscommunicating here somehow.

 

I currently have a Products.php file in the override/classes folder - "/store/override/classes/Product.php", which is 9k in size and was placed there by a 3rd party module.

 

If I create a Products.php file and place it in that folder as you mention above, it will overwrite the current Products.php file, rendering the 3rd party module non-functional.

 

Or maybe I'm misunderstanding what you're saying?

Share this post


Link to post
Share on other sites

I think you're right. I assume the initial reference (below) is just a typo to keep me on my toes?

 

I currently have a Products.php file in the override/classes folder - "/store/override/classes/Product.php", which is 9k in size and was placed there by a 3rd party module.

 

If you already have a override/classes/product.php, just add a public function to it.

 

// this function gets original price in the DB
public function getOriginalPrice($id)
{
 return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
 SELECT `price`
 FROM `'._DB_PREFIX_.'product`
 WHERE `id_product` = '.(int)($id));
}

 

 

Then you can copy ProductController.php to override, and add the 1 line of code in the appropriate spot. (near line 320 in latest PS version; add to the array that is assigning the smarty template variables). As before, if it already exists, just modify it.

 

// setting original price var
'originalPrice' => Product::getOriginalPrice($this->product->id),

 

Then modify the tpl file to show the original price as I did in the original post.

Share this post


Link to post
Share on other sites

Hey g0nzo,

 

Yup, I figured your fix would work well if I can get it into the current 3rd party Products.php. I haven't had a chance to look through it with everything else we've been doing to get the store set up, but it's on my list. The problem with editing the file to add the function above is that the Products.php file is 9k of obfuscated code (for code protection by the module vendor), so it won't be as easy as just adding the function and will take some time to do.

 

I'm sure your fix will work once I get that done, and I really appreciate the help with this...

Share this post


Link to post
Share on other sites

Hey CodeDog - Note there is a difference between PRODUCT.PHP (this is the one we want) and PRODUCTS.PHP - You are referring to it differently in every post so you should check to be sure you are in the right file.

 

Failing that you could try putting it in its own class, perhaps by inheriting the Product class. Not sure if that will work though.

 

Good luck!

Share this post


Link to post
Share on other sites

:P :P :P

 

I have to quit trying to do 17 things at once and pay more attention to what I'm typing. Everything should have been Product.php with no "S". Sorry about that. :(

 

I'll look into adding a class, good thought...

Share this post


Link to post
Share on other sites

:rolleyes: I thought you were messing with me! But I know how you feel.

 

There is another option too, of course. Since these are only tiny modifications, you could just modify the core file and make a note as well as comment the code so you can easily 'grep' for it when upgrading. Really we're only adding a function and not changing an existing one, so its not a big deal.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More