Post by carcaras3 » Mon Mar 26, 2018 4:33 am

Hi everyone.

I wrote a complex library with several functions I need on a store. But now I need to use that library within the cart library itself.
Is there a way to load a library within another, I have tried adding the code:
$cartfunctions = new Customcartfunctions($this->registry);
But it just doesn't work.

Any help will be really appreciated.



Mon Jul 31, 2017 8:19 pm

Post by Wid » Mon Mar 26, 2018 6:18 pm

$this->registry->set('Customcartfunctions', new Customcartfunctions($this->registry));

i have not tested if it works, but i believe so
reply if it works

take a visit to My Modules !

New member


Fri Feb 02, 2018 9:19 pm
Location - Athens/Greece

Post by straightlight » Mon Mar 26, 2018 7:53 pm

Another way to do it is with the $this->registry object being propagated inside the first instantiated class.

From your first method, by passing the $this->registry object, below the __construct method block of code, you could add:

Code: Select all

public function __get($name) {
    return $this->registry->get($name);
in order to keep using the Opencart Registry Object inside your constructor as if you were originally coding inside Opencart in theory. :)

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

Programmer / Opencart Tester

Legendary Member


Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 30 guests