Use overrides only as a last resort. If you must use them, create a dedicated module that programmatically writes the override files during installation, rather than committing them directly – this improves upgrade management. Report prepared for: PrestaShop Developers & Technical Architects Document version: 1.0 Last updated: 2025
// Apply VIP discount (example logic) if (Context::getContext()->customer->isLogged() && Customer::getInstance()->isVip()) $price = $price * 0.90; // 10% off prestashop override class
The override class must extend the *Core version of the original class (e.g., ProductCore ). 4. How the Override System Works (Flow) graph TD A[Request calls e.g. 'new Cart()'] --> B[Autoloader looks for class Cart] B --> CExists in /override/classes/ ? C -->|Yes| D[Load /override/classes/Cart.php] C -->|No| E[Load /classes/Cart.php] D --> F[Class Cart extends CartCore] F --> G[Execute override methods] E --> H[Execute original CartCore methods] PrestaShop uses a custom Autoload class that scans /override/ at runtime (or caches the mapping). When a class is instantiated, the autoloader loads the override version if present. 5. Creating an Override (Example) Goal: Modify the getProductPrice method in Product class to apply a special discount for VIP customers. Use overrides only as a last resort
| Original Core Path | Override Path | Class Name (Override) | |-------------------|---------------|------------------------| | /classes/Cart.php | /override/classes/Cart.php | class Cart extends CartCore | | /controllers/front/OrderController.php | /override/controllers/front/OrderController.php | class OrderController extends OrderControllerCore | | /core/Foundation/IoC/Container.php | /override/core/Foundation/IoC/Container.php | class Container extends ContainerCore | C -->|Yes| D[Load /override/classes/Cart