The Sales module is the final one in the series of modules we will build in order to deliver a simple yet functional web shop application. We will do so by adding the cart and the checkout features on top of the catalog. The checkout itself will finally make use of the shipping and payment services defined throughout the previous chapters. The overall focus here will be on absolute basics, since the real shopping cart application would take a far more robust approach. However, understanding how to tie it all together in a simple way is the first step toward opening up a door for more robust web shop application implementations later on.
In this chapter, we will be covering the following topics of the Sales module:
Application requirements, defined in Chapter 4, Requirement Specification for Modular Web Shop App, give us some wireframes relating to the cart and checkout. Based on these wireframes, we can speculate about what type of entities we need to create in order to deliver on functionality.
The following is a list of required module entities:
The Cart entity includes the following properties and their data types:
id: integer, auto-incrementcustomer_id: stringcreated_at: datetimemodified_at: datetimeThe Cart Item entity includes the following properties:
id: integer, auto-incrementcart_id: integer, foreign key that references the category table id columnproduct_id: integer, foreign key that references product table id columnqty: stringunit_price: decimalcreated_at: datetimemodified_at: datetimeThe Order entity includes the following properties:
id: integer, auto-incrementcustomer_id: integer, foreign key that references the customer table id columnitems_price: decimalshipment_price: decimaltotal_price: decimalstatus: stringcustomer_email: stringcustomer_first_name: stringcustomer_last_name: stringaddress_first_name: stringaddress_last_name: stringaddress_country: stringaddress_state: stringaddress_city: stringaddress_postcode: stringaddress_street: stringaddress_telephone: stringpayment_method: stringshipment_method: stringcreated_at: datetimemodified_at: datetimeThe Order Item entity includes the following properties:
id: integer, auto-incrementsales_order_id: integer, foreign key that references the order table id columnproduct_id: integer, foreign key that references product table id columntitle: stringqty: intunit_price: decimaltotal_price: decimalcreated_at: datetimemodified_at: datetimeAside from just adding these entities and their CRUD pages, we also need to override a core module service responsible for building the category menu and on-sale items.