Zrali Posted February 16 Share Posted February 16 Hi. I'm using Prestashop 1.7.8 and I have this problem. when customers delete an address at their end, the related orders to that address are not seen in the order section of Prestashop's backend. I wish to have a situation where even if a customer deletes and address, related orders to that address should still be shown at the orders section. Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 16 Share Posted February 16 3 hours ago, Zrali said: Hi. I'm using Prestashop 1.7.8 and I have this problem. when customers delete an address at their end, the related orders to that address are not seen in the order section of Prestashop's backend. I wish to have a situation where even if a customer deletes and address, related orders to that address should still be shown at the orders section. You could try with making an override. Head to override/classes/ and create file Address.php with code and clear cache after. <?php class AddressOverride extends Address { public function delete() { // Check if this address is linked to any orders $orders = Db::getInstance()->executeS(' SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_address_delivery = ' . (int)$this->id . ' OR id_address_invoice = ' . (int)$this->id '); if (!empty($orders)) { // Instead of deleting, mark it as inactive return Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'address SET deleted = 1 WHERE id_address = ' . (int)$this->id ); } // If no linked orders, proceed with normal deletion return parent::delete(); } } 1 Link to comment Share on other sites More sharing options...
Zrali Posted February 16 Author Share Posted February 16 6 hours ago, ComGrafPL said: You could try with making an override. Head to override/classes/ and create file Address.php with code and clear cache after. <?php class AddressOverride extends Address { public function delete() { // Check if this address is linked to any orders $orders = Db::getInstance()->executeS(' SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_address_delivery = ' . (int)$this->id . ' OR id_address_invoice = ' . (int)$this->id '); if (!empty($orders)) { // Instead of deleting, mark it as inactive return Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'address SET deleted = 1 WHERE id_address = ' . (int)$this->id ); } // If no linked orders, proceed with normal deletion return parent::delete(); } } Thanks very much for your response but after placing your codes into override/classes/Address.php , Orders were still deleted when a customer deletes an address related to an order at the frontend. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now