Adding a shopping cart for the application

In Chapter 5, Customization and Further Development, we saw how the generated application can be customized to make it look and behave like an e-commerce website. As mentioned there, it is not enough to make the application truly usable. The following are some of the features that you can try to implement to make the application more feature complete:

  1. Add a simple shopping cart feature on the client-side: 
    1. Create a ProductOrder object to hold the OrderItems. The ProductOrder is related to the Customer so tag it to the customer using details of the currently logged-in user.
    2. Add an add to cart button to the product items in the list. On clicking the button, create a new OrderItem for the Product and add the OrderItem to the ProductOrder's OrderItems array. If the same product is clicked more than once, increase the quantity attribute of the existing OrderItemAdd a shopping cart dialog to list down all the OrderItems added to the ProductOrder. It can use a similar listing UI to the products, or a simple table to show the product, total price, and quantity.
    3. Add a view cart button to the product list page to view the shopping cart dialog.
  1. Add an order now feature:
    1. Add an order now button to the product list page.
    2. On clicking the button, send the ProductOrder to the REST API to create a new ProductOrder, use the product-order.service.ts for this.
    3. At the backend, modify the save method of ProductOrderService.java to create an Invoice and Shipment for the ProductOrder and save them all.
    4. Let us assume that we accept cash on delivery so let us skip integrating with a payment gateway for now.
  2. Send an order confirmation to the customer:
    1. JHipster comes with mail configuration and templates out of the box. You can configure your own SMTP server details in src/main/resources/config/application-*.yml. Refer to http://www.jhipster.tech/tips/011_tip_configuring_email_in_jhipster.html for instructions on how to configure popular SMTP services.
    2. Create a new email template in src/main/resources/mails for order confirmation. Provide the details of products, total price, and quantity in the email.
    3. Use the provided sendEmailFromTemplate method in MailService.java to send the email when an Invoice is successfully created.
  3. Create a customer profile when registering a new user:
    1. Add fields to the registration page and create customer entity for every user from the details automatically.

Try to apply the changes to the microservice application as well.