go routine and removing cart

This commit is contained in:
Daniel Goc
2026-04-13 09:21:33 +02:00
parent d4d55e2757
commit 1f6d5ecb72
4 changed files with 35 additions and 3 deletions

View File

@@ -87,14 +87,24 @@ func (s *OrderService) PlaceNewOrder(user_id uint, cart_id uint, name string, co
if err != nil {
return err
}
// from this point onward we do not cancel this order.
// send email to admin
err = s.emailService.SendNewOrderPlacedNotification(user_id)
// if no error is returned, remove the cart. This should be smooth
err = s.cartsRepo.RemoveCart(user_id, cart_id)
if err != nil {
// Log error but don't fail placing order???
// Log error but don't fail placing order
_ = err
}
// send email to admin
go func(user_id uint) {
err := s.emailService.SendNewOrderPlacedNotification(user_id)
if err != nil {
// Log error but don't fail placing order
_ = err
}
}(user_id)
return nil
}