1 <?php
2 3 4 5 6 7 8 9 10
11
12 MainFactory::load_class('CustomerDeleterInterface');
13
14 15 16 17 18 19 20 21 22
23 class CustomerDeleter implements CustomerDeleterInterface
24 {
25 26 27 28
29 protected $db;
30
31
32 33 34 35 36
37 public function __construct(CI_DB_query_builder $dbQueryBuilder)
38 {
39 $this->db = $dbQueryBuilder;
40 }
41
42
43 44 45 46 47 48 49
50 public function delete(CustomerInterface $customer)
51 {
52 $customerId = (int)(string)$customer->getId();
53 $this->db->delete('address_book', array('customers_id' => $customerId));
54 $this->db->delete('admin_access', array('customers_id' => $customerId));
55 $this->db->delete('customers', array('customers_id' => $customerId));
56 $this->db->delete('customers_basket', array('customers_id' => $customerId));
57 $this->db->delete('customers_basket_attributes', array('customers_id' => $customerId));
58 $this->db->delete('customers_info', array('customers_info_id' => $customerId));
59 $this->db->delete('customers_ip', array('customers_id' => $customerId));
60 $this->db->delete('customers_status_history', array('customers_id' => $customerId));
61 $this->db->delete('customers_wishlist', array('customers_id' => $customerId));
62 $this->db->delete('customers_wishlist_attributes', array('customers_id' => $customerId));
63 $this->db->delete('coupon_gv_customer', array('customer_id' => $customerId));
64 $this->db->delete('coupon_gv_queue', array('customer_id' => $customerId));
65 $this->db->delete('coupon_redeem_track', array('customer_id' => $customerId));
66 $this->db->delete('gm_gprint_cart_elements', array('customers_id' => $customerId));
67 $this->db->delete('gm_gprint_wishlist_elements', array('customers_id' => $customerId));
68 $this->db->delete('products_notifications', array('customers_id' => $customerId));
69 $this->db->delete('whos_online', array('customer_id' => $customerId));
70
71 $this->db->update('coupon_redeem_track', array('customer_id' => 0), array('customer_id' => $customerId));
72 $this->db->update('gm_gprint_uploads', array('customers_id' => 0), array('customers_id' => $customerId));
73 $this->db->update('newsletter_recipients', array('customers_id' => 0), array('customers_id' => $customerId));
74 $this->db->update('orders', array('customers_id' => 0), array('customers_id' => $customerId));
75 $this->db->update('withdrawals', array('customer_id' => 0), array('customer_id' => $customerId));
76
77 return $this;
78 }
79 }