Dipak Kumar Pusti
Dipak Kumar Pusti

Reputation: 1723

Extending the Cart page in opencart

The cart page located in /system/library/ holds all the control for calculation and the further proceedings in the cart and checkout.

As I am changing the system to make it work differently, I need to write some code in the system file i.e. Cart.php.

So I want to extend this cart page so that I can hold my newly created functions there. How can I do it. Or is there any other way to keep the new functions.

Upvotes: 0

Views: 265

Answers (1)

shadyyx
shadyyx

Reputation: 16055

The best bet is to write down Your own class, e.g. /system/library/my_cart.php that will extend from the original class, like this:

class MyCart extends Cart {
    // ...
}

Here You can place all Your new functions, new stuff, make overrides to functions from Cart class, etc.

Then, in index.php make sure to add:

require_once(DIR_SYSTEM . 'library/my_cart.php');

after

require_once(DIR_SYSTEM . 'library/cart.php');

and to change

$registry->set('cart', new Cart($registry));

to this

$registry->set('cart', new MyCart($registry));

That should be it...

But if You do not want to overwrite either the index.php, then the last option is using vQmod...

Upvotes: 3

Related Questions