Jump to content

Get the category ID in product.tpl


Recommended Posts

I need to display a different stock message on the product page when a product from a certain category has been sold.

 

So I would like to do something like this

 

{if defaultCategoryID == 8} {l s='Sold'} {else} {l s='Currently out of stock'}{/if}

 

I don't think you can grab the default category from an already established smarty variable in Product.tpl correct me if I am wrong, I think I may have to override/extend the ProductCore class. If so how would be the best way to achieve this or is there a better way?

 

I'm using PrestaShop 1.6.1.5

Edited by Chillax86 (see edit history)
Link to comment
Share on other sites

Unfortunately, there's no easy way to see all the Smarty variables on a page. You can find the PHP file that calls the TPL file to see what variables are assigned there. You can also read through the init function in classes/controller/FrontController.php to see what Smarty variables are assigned on all pages.

Link to comment
Share on other sites

  • 3 weeks later...

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