1 00:00:02,270 --> 00:00:03,700 For clearing the cart, 2 00:00:03,760 --> 00:00:04,430 that's simple, 3 00:00:04,490 --> 00:00:06,860 we are dispatching this add order 4 00:00:06,860 --> 00:00:08,210 action in the end. 5 00:00:08,240 --> 00:00:14,540 Now of course, this action is currently handled in our orders reducer but we're not limited to handing 6 00:00:14,540 --> 00:00:15,020 it there, 7 00:00:15,020 --> 00:00:21,500 it's important to understand that every Redux action you dispatch reaches every reducer because how would 8 00:00:21,500 --> 00:00:23,960 the action know to which reducer it belongs? 9 00:00:23,960 --> 00:00:29,510 As I explained earlier, it's the reducer that simply tells which actions it cares about and which actions 10 00:00:29,510 --> 00:00:30,830 should not be handled. 11 00:00:31,160 --> 00:00:35,990 So the add order action can also be handled in the cart reducer, 12 00:00:35,990 --> 00:00:42,120 alternatively you could dispatch a separate clear cart action if you wanted to but if you don't need 13 00:00:42,120 --> 00:00:47,400 that anywhere else, there's not really a strong reason to create a separate action. So I will just handle 14 00:00:47,420 --> 00:00:54,260 the already existing add order action here in my cart reducer and there after handling the remove case, 15 00:00:54,970 --> 00:01:01,820 I'll handle the add order action and for that, you just need to make sure you import this add order action 16 00:01:01,940 --> 00:01:08,810 from the actions folder and there, from the orders file and now in that case down there, we need to clear 17 00:01:08,810 --> 00:01:10,540 the cart and that's super simple, 18 00:01:10,550 --> 00:01:17,090 we just need to return our initial state again because initial state in here is of course this object 19 00:01:17,480 --> 00:01:20,630 with an empty cart and a total amount of zero. 20 00:01:20,690 --> 00:01:22,210 So I just want to reset this, 21 00:01:22,250 --> 00:01:24,320 hence this is what I return here. 22 00:01:24,380 --> 00:01:30,200 The result of this is that if I add items to a cart here, let's say two red shirts and one blue carpet 23 00:01:30,200 --> 00:01:30,920 and I click order 24 00:01:30,920 --> 00:01:35,990 now, the cart is cleared and now we see the order here still, 25 00:01:35,990 --> 00:01:37,310 that's our order. 26 00:01:37,550 --> 00:01:38,900 So that's how we can clear the cart, 27 00:01:39,050 --> 00:01:41,060 let's now make sure the order looks nicer.