From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Get item for cart

Get item for cart

Alright guys, so in the last video we made it so that we get a session cart ID as soon as we come to the site Whether we're signed in or not Now we're going to start to work on the action which right now if I if I click add to cart we get a little toast notification, but all it's doing in the action is Just sending that object. That's not doing anything else. There's no cart functionality So in order for this to work, we have to do a couple things We have to get the user, and if we're not logged in, that user will be undefined. And then we have to get the product that we're adding from the database. So if I want to add this Calvin Klein shirt to my cart, I have to fetch it from the database first so that I have that information, I have that data. So that's what we're going to do in this video. And then in the next one, we'll continue and do the insert to the cart table. All right. Now, we're going to start off here. Let's see. How do we want to start off? Let's bring in, we have to…

Contents