When we built a product we first create core of that product which contains bare minimal functionalities of products and then build other advance features around it. Now one more important thing is to make it extensible and easy for customization because everyone wants to give their own flavors to their store. Opencart is very flexible in that area. Opencart has library of API which can be utilize to extend core features.Libraries are very important part of OpenCart. They are helper files, which are most often used when developing something.
Libraries can be found in root>system>library as shown below.
Some of the commonly used libraries:
- db.php: Here you can find all database related APIs.
- customer.php: This library contains customer-related features
- config.php:This libreary contains all OpenCart store settings
- user.php: contains all of the administrator and user features
- cart.php: It has cart-related features
- image.php: It contains image-related features such as like image cropping, caching, and more.
- session.php: Here you can find api related to session management.
- encryption.php: It contains API to manage encryption.
Most of these libraries are self explanatory and other things I liked is they have not overloaded any of the library and created small small APIs which can be used as utility methods.
Syntax of loading a library is as follow: $this->library_name.
For instance, to programmatically log a user into the system: $this->user->login($username,$password);
To log a user out of the system, you could use $this->user->logout();