aboutsummaryrefslogtreecommitdiff
path: root/customer/hooks.go
diff options
context:
space:
mode:
Diffstat (limited to 'customer/hooks.go')
-rw-r--r--customer/hooks.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/customer/hooks.go b/customer/hooks.go
index ac246f3..bef3308 100644
--- a/customer/hooks.go
+++ b/customer/hooks.go
@@ -39,5 +39,19 @@ func (c *Customer) BeforeDelete(tx *gorm.DB) error {
return errors.ErrNoWhereCondition
}
+ var err error
+
+ // delete billing address
+ err = db.Where("customer_id = ?", c.ID).Delete(&CustomerBillingAddress{}).Error
+ if err != nil {
+ return err
+ }
+
+ // delete shipping addresses
+ err = db.Where("customer_id = ?", c.ID).Delete(&CustomerShippingAddress{}).Error
+ if err != nil {
+ return err
+ }
+
return nil
}