Override Prestashop Site
Override Prestashop Site
public function installOverrides()
❌ You can do the same with a hook, template, or module configuration. 9. Common Pitfalls & Solutions | Problem | Solution | |---------|----------| | White screen after override | Check PHP error log; verify you extended the correct parent class ( XXXCore ) | | Override ignored | Delete /var/cache/prod/class_index.php and clear cache | | Conflict between two modules | One will win; override should be inside a custom module, not directly in /override/ | | Override breaks after PS update | Review changelog – your overridden method may have changed signature | | Can't override static methods | You can, but careful; call parent::method() if needed | 10. Best Practice – Use a Custom Module Instead of placing files directly in /override/ , put overrides inside a custom module :
/classes/Cart.php
✅ You must modify a core method’s logic, add a new property/method to a core class, or change core controller flow.
<?php // override/controllers/admin/AdminOrdersController.php class AdminOrdersController extends AdminOrdersControllerCore override prestashop
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) // Get original cost $originalCost = parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone); // Apply custom logic (e.g., free shipping over $100) if ($this->getOrderTotal(true, Cart::ONLY_PRODUCTS) > 100) return 0; return $originalCost;
grep "YourClassName" /var/cache/prod/class_index.php If you tell me (e.g., change payment fee, add product field, modify order status logic), I can give you a precise working code example. public function installOverrides() ❌ You can do the
Then use $custom_product_discount in product.tpl or .tpl files. Goal: Modify module’s front controller.