April 2020
Intermediate to advanced
716 pages
18h 55m
English
The user will see the option to perform the checkout depending on whether they are signed in and whether the checkout has already been opened, as implemented in the following code.
mern-marketplace/client/cart/CartItems.js:
{!props.checkout && (auth.isAuthenticated() ? <Button onClick={openCheckout}> Checkout </Button> : <Link to="/signin"> <Button>Sign in to checkout</Button> </Link>)}
When the checkout button is clicked, the openCheckout method will use the setCheckout method passed as a prop to set the checkout value to true in the Cart component. The openCheckout method is defined as follows.
mern-marketplace/client/cart/CartItems.js:
const openCheckout = () => { props.setCheckout(true)}
Once the checkout value is ...
Read now
Unlock full access