April 2020
Intermediate to advanced
716 pages
18h 55m
English
In this section, we will create the checkout view, which contains the form fields and the place order option in a Checkout component. In this component, we will initialize the checkoutDetails object in the state before collecting the details from the form. We will prepopulate the customer details based on the current user's details and add the current cart items to checkoutDetails, as shown in the following code.
mern-marketplace/client/cart/Checkout.js:
const user = auth.isAuthenticated().user const [values, setValues] = useState({ checkoutDetails: { products: cart.getCart(), customer_name: user.name, customer_email:user.email, delivery_address: { street: '', city: '', state: '', zipcode: '', country:''}Read now
Unlock full access