Jump to content

Call function in cart-detailed-product-line


13thjoker
 Share

Recommended Posts

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 by 13thjoker (see edit history)

Share this post


Link to post
Share on other sites

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"

 

  • Like 1

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

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