// Do not delete customer addresses when delete it
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17567 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+32
-5
@@ -240,14 +240,41 @@ class CustomerCore extends ObjectModel
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$addresses = $this->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
foreach ($addresses as $address)
|
||||
if (!count(Order::getCustomerOrders((int)$this->id)))
|
||||
{
|
||||
$obj = new Address((int)$address['id_address']);
|
||||
$obj->delete();
|
||||
$addresses = $this->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
foreach ($addresses as $address)
|
||||
{
|
||||
$obj = new Address((int)$address['id_address']);
|
||||
$obj->delete();
|
||||
}
|
||||
}
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'customer_group` WHERE `id_customer` = '.(int)$this->id);
|
||||
CartRule::deleteByIdCustomer((int)$this->id);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'message WHERE id_customer='.(int)$this->id);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_customer='.(int)$this->id);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'compare WHERE id_customer='.(int)$this->id);
|
||||
|
||||
$carts = Db::getInstance()->executes('SELECT id_cart
|
||||
FROM '._DB_PREFIX_.'cart
|
||||
WHERE id_customer='.(int)$this->id);
|
||||
if ($carts)
|
||||
foreach ($carts as $cart)
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart WHERE id_cart='.(int)$cart['id_cart']);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart_product WHERE id_cart='.(int)$cart['id_cart']);
|
||||
}
|
||||
|
||||
$cts = Db::getInstance()->executes('SELECT id_customer_thread
|
||||
FROM '._DB_PREFIX_.'customer_thread
|
||||
WHERE id_customer='.(int)$this->id);
|
||||
if ($cts)
|
||||
foreach ($cts as $ct)
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'customer_thread WHERE id_customer_thread='.(int)$ct['id_customer_thread']);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'customer_message WHERE id_customer_thread='.(int)$ct['id_customer_thread']);
|
||||
}
|
||||
|
||||
Discount::deleteByIdCustomer((int)$this->id);
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user