Custom helper functions in OpenCart

opencart, php

Solution

Put your helper file inside a helper folder inside a system directory

`system/helper/myhelper.php`

and include it to

`system/startup.php` file

like this

`require_once(DIR_SYSTEM . 'helper/myhelper.php');`

and you are done.

Problem

Trying to create a custom PHP function within opencart. Basically I need to know if we are viewing the cart or checkout pages. I understand the simplest way to accomplish this is by accessing the route request param. I want to create a re-usable function however that is available site wide. Is this possible? Where would it go? The function looks something like this: ``` function isCheckout() { $route = $this->request->get['route']; //is cart? if($route == 'checkout/cart') return 'cart'; $parts = explode('/', $route); if($parts[0] == 'checkout') return 'checkout'; return false; } ```

Original source