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 we 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:

  • 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 the 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 OrderItems array of the ProductOrder. 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.

  • Add an Order Now feature:
    1. Add an Order Now button to the product list page.
    2. On clicking the button, send the ProductOrder entity 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's assume that we accept cash on delivery, so let's skip integration with a payment gateway for now.
  • 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/templates/mail 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.
  • Create a customer profile when registering a new user:
    1. Add fields to the registration page and create a customer entity for every user from the details automatically.

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.193.129