João Nascimento Posted August 5, 2016 Share Posted August 5, 2016 Hello, I need to create a global variable to use in .tpl files. Who I can do this? The variable is to write in /classes/cart.php and after call in .tpl file. Best regards Link to comment Share on other sites More sharing options...
shokinro Posted August 5, 2016 Share Posted August 5, 2016 You question is not clear, please try to make your question more clear so that you will get answered quickly. what variable and for what purpose. Is it using in shopping page only? You can use some kind of code as following in initContent() of the page controller. $this->context->smarty->assign('variable', $value); Link to comment Share on other sites More sharing options...
João Nascimento Posted August 5, 2016 Author Share Posted August 5, 2016 You question is not clear, please try to make your question more clear so that you will get answered quickly. what variable and for what purpose. Is it using in shopping page only? You can use some kind of code as following in initContent() of the page controller. $this->context->smarty->assign('variable', $value); In /classes/cart.php file I added a calculation to calculate me the extra value of combinations of products. I wanted to save that resulting value and call ii in a .tpl page to just display the result. Link to comment Share on other sites More sharing options...
shokinro Posted August 5, 2016 Share Posted August 5, 2016 In /classes/cart.php file I added a calculation to calculate me the extra value of combinations of products. I wanted to save that resulting value and call ii in a .tpl page to just display the result. From what I see, I think the variable is per product(each product has the value), right? If that is the case, you need to add that value to product level(each product). The smarty variable for $products should have been assigned already, you only need to add the value to the product entity. 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