From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Enabling quantity selection - Next.js Tutorial
From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Enabling quantity selection
Next, I want to implement the functionality where the quantity can be increased or decreased with size selection. So first we will implement size selection functionality. For that I will receive the set cart item from the use product context hook. Now I will add the value attribute is equal to size dot value and check item size is equal to size dot value and finally I will say on change set cart items will say previous dot map product product dot id is equal to item dot id. If it is true, then I will change the value of the size and make the quantity equal to 1. Otherwise, we will say product. Alright, let's save the code and check. And we are able to select the size options. Now we will work on increasing or decreasing the quantity of the product functionality. For that, I will navigate to the product provider component and create a function for increasing product quantity. So the logic will be to find the product by its id first and then increment the quantity by 1. So I will say…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Initiating client section1m 53s
-
(Locked)
Creating header component5m 20s
-
(Locked)
Implementing search bar2m 16s
-
(Locked)
Joining Tailwind classes with ideal approach2m 34s
-
(Locked)
RQ: Joining Tailwind classes with ideal approach2m 38s
-
(Locked)
Adding profile drop-down4m 31s
-
(Locked)
useRef() hook4m 42s
-
(Locked)
Close profile drop-down menu on outside click3m 2s
-
(Locked)
RQ: Close profile drop-down menu on outside click2m 36s
-
(Locked)
Creating input component1m 54s
-
(Locked)
Creating home page2m 34s
-
(Locked)
Creating filters section6m 15s
-
(Locked)
Creating custom accordion component10m 58s
-
(Locked)
RQ: Creating custom accordion component1m 37s
-
(Locked)
Completing custom accordion component4m 35s
-
(Locked)
Continue on filter section3m 2s
-
(Locked)
Creating price range slider component4m 39s
-
(Locked)
Creating product card component8m 17s
-
(Locked)
Completing product card component2m 47s
-
(Locked)
Creating button component1m 44s
-
(Locked)
API creation for product listing3m 59s
-
(Locked)
Dynamic product rendering using server action7m 12s
-
(Locked)
API creation for fetching product types1m 41s
-
(Locked)
Dynamic product type rendering using API2m 28s
-
(Locked)
Set filter values into the search params4m 29s
-
(Locked)
Modifying products API to apply filters5m 35s
-
(Locked)
Filter functionality on client side3m 44s
-
(Locked)
Search filter functionality4m 31s
-
(Locked)
Creating product page6m 38s
-
(Locked)
Completing product page3m 21s
-
(Locked)
API creation for fetching a product by its ID2m 54s
-
(Locked)
Dynamic product details rendering using API3m 25s
-
(Locked)
Rendering products based on status2m 42s
-
(Locked)
Creating cart page3m 24s
-
(Locked)
Rendering cart item card6m 22s
-
(Locked)
Completing the cart UI4m 55s
-
(Locked)
Creating context for handling products1m 50s
-
(Locked)
RQ: Creating context for handling products1m 28s
-
(Locked)
Implement cart functionalities8m 4s
-
(Locked)
Making cart page dynamic2m 54s
-
(Locked)
Enabling quantity selection3m 45s
-
(Locked)
Finishing dynamic cart page5m 6s
-
(Locked)
-
-
-
-