13thjoker Posted October 25, 2017 Share Posted October 25, 2017 (edited) So i wrote the next function in CartConroller.php public function TestFunction() { $page = "hi" return $page; } And then tried to use the function using {Cart::TestFunction()} Can somebody point out what i need to do to make it work Thanks already vers: 1.7.2.3 Edited October 25, 2017 by 13thjoker (see edit history) Link to comment Share on other sites More sharing options...
AlexNDR.mac Posted October 25, 2017 Share Posted October 25, 2017 If you want to call function by this way - you need to create static function class ClassName { // need instance of class public function TestFunction() { $page = "hi" return $page; } // call staticaly by class name public static function TestFunctionStatic() { $page = "hi" return $page; } } this example help you to understand // create object instance $testObj = new ClassName(); // call public method $testObj->TestFunction(); // will return "hi" // call static method $testObj = ClassName::TestFunctionStatic(); // $testObj now contains "hi" 1 Link to comment Share on other sites More sharing options...
13thjoker Posted October 26, 2017 Author Share Posted October 26, 2017 This actually helped me alot understand how it works! Thanks so much Link to comment Share on other sites More sharing options...
13thjoker Posted October 26, 2017 Author Share Posted October 26, 2017 Update: it gives me this now UndefinedMethodException in smarty_internal_templatebase.php(171) : eval()'d code line 882: Attempted to call an undefined method named "TestFunctionStatic" of class "CartControllerCore". in smarty_internal_templatebase.php(171) : eval()'d code line 882 Link to comment Share on other sites More sharing options...
13thjoker Posted October 26, 2017 Author Share Posted October 26, 2017 Can someone explain me using exactly same code just different install why it doesnt give this error anymore. Does prestashop just hate me? 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