diff --git a/src/checkoutservice/main.go b/src/checkoutservice/main.go
index 78b4b94..15cf5fa 100644
--- a/src/checkoutservice/main.go
+++ b/src/checkoutservice/main.go
@@ -96,6 +96,8 @@ func (cs *checkoutService) PlaceOrder(ctx context.Context, req *pb.PlaceOrderReq
return nil, status.Errorf(codes.Unavailable, "shipping error: %+v", err)
}
+ _ = cs.emptyUserCart(ctx, req.UserId)
+
orderResult := &pb.OrderResult{
OrderId: orderID.String(),
ShippingTrackingId: shippingTrackingID,
@@ -175,6 +177,19 @@ func (cs *checkoutService) getUserCart(ctx context.Context, userID string) ([]*p
return cart.GetItems(), nil
}
+func (cs *checkoutService) emptyUserCart(ctx context.Context, userID string) error {
+ conn, err := grpc.DialContext(ctx, cs.cartSvcAddr, grpc.WithInsecure())
+ if err != nil {
+ return fmt.Errorf("could not connect cart service: %+v", err)
+ }
+ defer conn.Close()
+
+ if _, err = pb.NewCartServiceClient(conn).EmptyCart(ctx, &pb.EmptyCartRequest{UserId: userID}); err != nil {
+ return fmt.Errorf("failed to empty user cart during checkout: %+v", err)
+ }
+ return nil
+}
+
func (cs *checkoutService) prepOrderItems(ctx context.Context, items []*pb.CartItem, userCurrency string) ([]*pb.OrderItem, error) {
out := make([]*pb.OrderItem, len(items))
diff --git a/src/frontend/templates/footer.html b/src/frontend/templates/footer.html
index acfdca7..9d94cde 100644
--- a/src/frontend/templates/footer.html
+++ b/src/frontend/templates/footer.html
@@ -1,6 +1,6 @@
{{ define "footer" }}
- This is a demo application. ({{$.session_id}})
+ This is a demo application, not a real retail business. ({{$.session_id}})