andref Posted August 29, 2017 Share Posted August 29, 2017 (edited) Hello there, I'm making a module to display some shipping information on the product page, I've hooked the module to "ExtraRight" to show up in the product page. I have most of what I want working apart from one thing. I want to check if the price of the product is higher than 35€ displays something and if it's lower display something else. I've tried a bunch of diferent code snippets without any luck, I can get the price without taxes, but I need to check the price with taxes included, and that's my problem, I can't get the price with the taxes included. Here's the code I have that get's me the price without taxes. I'm working on the tpl file of the module. Using PS 1.6.1.16 {if $product->price >= 35} <div> Something </div> {else} <div> Something else </div> {/if} I've tried several diferent variables with no luck. If anyone could help me I would really appreciate it. Thank You! Edited August 29, 2017 by andref (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted August 29, 2017 Share Posted August 29, 2017 (edited) You can find the answer in product.tpl - all is already there. And you might note the fact that prices show can change with different customers groups if you have set up different pricing models for different customer groups. And - sey prestashop version you use. If on V 1.7 forget everything I wrote. Edited August 29, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
andref Posted August 29, 2017 Author Share Posted August 29, 2017 That was my first move, go to product.tpl and "copy" what was done there, but I couldn't figure out how after trying a bunch of diferent things. I'm not using diferent prices for diferent groups. I tried, as used in the product.tpl {$productPrice} But that does't work. I tested all my code to display the price of the product on the page just to see if it was returning what the price as I wanted, and with this it doesn't return nothing. Thank You. Link to comment Share on other sites More sharing options...
Scully Posted August 29, 2017 Share Posted August 29, 2017 If would start adding this to my product.tpl with no if. Just display the value. <h3>Price: $productPrice</h3> If this works with the correct price, the if isn't a problem. Link to comment Share on other sites More sharing options...
andref Posted August 30, 2017 Author Share Posted August 30, 2017 I've tried that, I've tried: {if $productPrice >= 35} <div>...</div> {else} <div>...</div> {/if} And nohting happens... And tried just to display the price: {$productPrice} I tried this on the product page on other place than the price block and it returns the price that I want with taxes, but when I use it in the template file of the hook ExtraRight it returns nothing, I don't know why, it is on the product page and it should have access to that Thank You. Link to comment Share on other sites More sharing options...
Scully Posted August 30, 2017 Share Posted August 30, 2017 productPrice works in product.tpl, if you use another template or hook it's another story. Link to comment Share on other sites More sharing options...
andref Posted August 30, 2017 Author Share Posted August 30, 2017 Yes, as I said in the original post, I'm making a module that is hooked to the ExtraRight hook in the product page. And as I said in the second reply I used {$product->price} Which returns me the price without taxes, but I need the price with taxes included. Any ideas on this? Thank You. Link to comment Share on other sites More sharing options...
Scully Posted August 30, 2017 Share Posted August 30, 2017 from class product ... public function getPrice($tax = true, $id_product_attribute = null, $decimals = 6, $divisor = null, $only_reduc = false, $usereduc = true, $quantity = 1) Link to comment Share on other sites More sharing options...
andref Posted August 30, 2017 Author Share Posted August 30, 2017 Doesn't work either... I'm going to change my plans and put this on the product template, it's easier and cleaner that way. Thank you for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now