1
00:00:02,440 --> 00:00:05,480
And I'll name that method save here.

2
00:00:05,480 --> 00:00:07,740
And since we'll interact with the database,

3
00:00:07,740 --> 00:00:10,700
I will also already add our import

4
00:00:10,700 --> 00:00:14,780
to our DB utility functionality

5
00:00:14,780 --> 00:00:17,803
in the data folder and there the database file.

6
00:00:20,250 --> 00:00:23,800
In the save method, we then have to differentiate

7
00:00:23,800 --> 00:00:25,110
between the two cases

8
00:00:25,110 --> 00:00:27,840
that we are updating an existing order

9
00:00:27,840 --> 00:00:30,233
or that we're storing a brand new order.

10
00:00:31,570 --> 00:00:34,680
We can differentiate by checking if we have an ID.

11
00:00:34,680 --> 00:00:36,640
If this ID is truthy,

12
00:00:36,640 --> 00:00:39,210
then we are updating.

13
00:00:39,210 --> 00:00:40,970
Else, if it's not truthy,

14
00:00:40,970 --> 00:00:42,613
we are adding a new order.

15
00:00:43,550 --> 00:00:45,943
Now let's start with that new order case.

16
00:00:46,870 --> 00:00:51,050
Here, I then want to create my order document

17
00:00:51,050 --> 00:00:53,850
that will be inserted into the database

18
00:00:53,850 --> 00:00:55,380
as a JavaScript object

19
00:00:55,380 --> 00:00:57,623
using this object literal notation,

20
00:00:58,810 --> 00:01:03,570
and there I'll set userData equal to this user data.

21
00:01:03,570 --> 00:01:07,660
So the data that's stored in my userData property here.

22
00:01:07,660 --> 00:01:09,410
And this will always be there.

23
00:01:09,410 --> 00:01:11,650
This is a non-optional argument

24
00:01:11,650 --> 00:01:12,763
in the constructor.

25
00:01:14,200 --> 00:01:16,700
I will store my product data

26
00:01:16,700 --> 00:01:19,233
by reaching out to this product data.

27
00:01:20,620 --> 00:01:24,660
And now I want to save the date, but there,

28
00:01:24,660 --> 00:01:27,580
since I'm adding a brand new document,

29
00:01:27,580 --> 00:01:30,139
I don't have a date yet.

30
00:01:30,139 --> 00:01:32,920
Therefore, I'll get a new date by simply

31
00:01:32,920 --> 00:01:34,873
calling new date like this.

32
00:01:35,730 --> 00:01:37,400
This creates a date object,

33
00:01:37,400 --> 00:01:40,030
and if you don't pass any value to it,

34
00:01:40,030 --> 00:01:43,470
it will use the current date-time snapshot.

35
00:01:43,470 --> 00:01:46,300
And that can then be stored to Mongo DB

36
00:01:46,300 --> 00:01:48,390
because thankfully Mongo DB knows

37
00:01:48,390 --> 00:01:51,823
how to work with such JavaScript date snapshots.

38
00:01:53,620 --> 00:01:54,530
Last but not least,

39
00:01:54,530 --> 00:01:57,530
I'll set the status to this.status,

40
00:01:57,530 --> 00:01:59,853
which as a default is pending.

41
00:02:01,850 --> 00:02:03,920
So that is my order document,

42
00:02:03,920 --> 00:02:05,690
which I want to store.

43
00:02:05,690 --> 00:02:10,039
And therefore, now we can use db getDb,

44
00:02:10,039 --> 00:02:13,480
and then reach out to, let's say, our orders collection,

45
00:02:13,480 --> 00:02:14,880
which doesn't exist yet,

46
00:02:14,880 --> 00:02:16,590
but which will simply be created

47
00:02:16,590 --> 00:02:18,203
on the fly when we need it.

48
00:02:19,230 --> 00:02:22,750
And there, I want to insert one new document

49
00:02:22,750 --> 00:02:24,763
and that's my order document.

50
00:02:28,170 --> 00:02:30,110
Of course, this returns a promise

51
00:02:30,110 --> 00:02:32,420
and therefore we could await this

52
00:02:32,420 --> 00:02:34,810
and add async in front of save.

53
00:02:34,810 --> 00:02:36,610
But since I don't do anything thereafter,

54
00:02:36,610 --> 00:02:39,010
I can also just return that promise,

55
00:02:39,010 --> 00:02:41,540
and therefore save will return that promise,

56
00:02:41,540 --> 00:02:43,270
which is yielded by insertOne,

57
00:02:43,270 --> 00:02:45,310
and we can handle it in the place

58
00:02:45,310 --> 00:02:47,683
where we call this save method here.

59
00:02:49,640 --> 00:02:52,730
Now that's the scenario for adding a new order.

60
00:02:52,730 --> 00:02:54,550
We'll work on updating later.

61
00:02:54,550 --> 00:02:56,460
For the moment, let's wire this up

62
00:02:56,460 --> 00:02:58,163
to our orders controller.

63
00:02:59,390 --> 00:03:03,930
Here, we now want to use our order model.

64
00:03:03,930 --> 00:03:07,470
So let's import it with require

65
00:03:07,470 --> 00:03:09,090
by going up one level,

66
00:03:09,090 --> 00:03:11,943
diving into models, and then order model.

67
00:03:13,970 --> 00:03:16,210
And then we can create our order here

68
00:03:16,210 --> 00:03:17,923
with new order.

69
00:03:18,930 --> 00:03:22,960
And now we need to pass some data to this constructor.

70
00:03:22,960 --> 00:03:24,810
For example, our cart.

71
00:03:24,810 --> 00:03:26,463
That's not too difficult.

72
00:03:28,550 --> 00:03:31,700
But we also need to pass some user data in there.

73
00:03:31,700 --> 00:03:34,970
And for this, we, first of all, need to fetch data

74
00:03:34,970 --> 00:03:36,323
about that user.

75
00:03:38,050 --> 00:03:40,560
Now, if we have a look at our user model,

76
00:03:40,560 --> 00:03:43,610
which we defined way earlier in this section,

77
00:03:43,610 --> 00:03:45,270
then we see that in there

78
00:03:45,270 --> 00:03:48,283
we have a getUserWithSameEmail method.

79
00:03:49,450 --> 00:03:52,720
Now I actually want to get a user by ID though,

80
00:03:52,720 --> 00:03:54,720
because the ID is something

81
00:03:54,720 --> 00:03:56,283
we have stored in our session.

82
00:03:57,260 --> 00:04:00,540
If we have a look at the check-auth middleware,

83
00:04:00,540 --> 00:04:03,300
we do get the user ID here

84
00:04:03,300 --> 00:04:04,810
from the UID field

85
00:04:04,810 --> 00:04:07,913
and we store that in res.locals.uid as well.

86
00:04:09,660 --> 00:04:11,920
Hence, I'll go to my user model

87
00:04:11,920 --> 00:04:15,020
and add a new static method,

88
00:04:15,020 --> 00:04:17,320
a static async method findById

89
00:04:18,180 --> 00:04:20,110
to find a user by ID

90
00:04:20,110 --> 00:04:22,903
and return some data about a user by ID.

91
00:04:25,070 --> 00:04:27,640
For this here I expect to get the user ID

92
00:04:27,640 --> 00:04:29,393
as a parameter value.

93
00:04:30,280 --> 00:04:31,690
And then, first of all,

94
00:04:31,690 --> 00:04:36,510
I'll transform it into a new Mongo DB user ID

95
00:04:36,510 --> 00:04:41,510
by importing Mongo DB at the top here,

96
00:04:41,520 --> 00:04:42,993
like this,

97
00:04:44,480 --> 00:04:45,713
with a semi-colon.

98
00:04:46,780 --> 00:04:49,953
And then here we can run new mongodb.ObjectId,

99
00:04:50,920 --> 00:04:52,613
and pass user ID to that.

100
00:04:55,150 --> 00:04:57,040
Now as our next step,

101
00:04:57,040 --> 00:05:00,410
I, of course, want to use db.getDb,

102
00:05:00,410 --> 00:05:03,620
and reach out to my users collection.

103
00:05:03,620 --> 00:05:05,920
And there find one user

104
00:05:06,760 --> 00:05:09,413
where _id is equal to the uid.

105
00:05:13,340 --> 00:05:16,570
Now, I will actually add a second parameter value here

106
00:05:16,570 --> 00:05:20,960
to find one, which allows me to apply projection.

107
00:05:20,960 --> 00:05:23,210
That means I can control which kind of fields

108
00:05:23,210 --> 00:05:25,330
I want to get or not get.

109
00:05:25,330 --> 00:05:27,770
And I don't want to extract the password

110
00:05:27,770 --> 00:05:28,963
from the database, for example,

111
00:05:28,963 --> 00:05:31,090
because I don't need that.

112
00:05:31,090 --> 00:05:33,320
We can make sure that it's not retrieved,

113
00:05:33,320 --> 00:05:35,120
but all the other data is,

114
00:05:35,120 --> 00:05:37,913
by adding password minus one here.

115
00:05:39,220 --> 00:05:41,030
This second parameter value,

116
00:05:41,030 --> 00:05:42,780
which you pass to findOne,

117
00:05:42,780 --> 00:05:46,164
controls which kind of data you want to receive.

118
00:05:46,164 --> 00:05:48,000
And if you set a field to minus one here,

119
00:05:48,000 --> 00:05:50,010
it will be excluded from the data

120
00:05:50,010 --> 00:05:51,060
that's being fetched.

121
00:05:52,920 --> 00:05:55,080
So now we can return this here,

122
00:05:55,080 --> 00:05:57,750
and actually we don't even need async therefore,

123
00:05:57,750 --> 00:05:59,760
since I directly return the promise

124
00:05:59,760 --> 00:06:01,333
that's yielded by findOne.

125
00:06:02,850 --> 00:06:06,160
And this will then give us the user document.

126
00:06:06,160 --> 00:06:08,980
Not a user model instance,

127
00:06:08,980 --> 00:06:10,740
not an instance of this class,

128
00:06:10,740 --> 00:06:12,790
but just the pure document.

129
00:06:12,790 --> 00:06:14,200
But for our purposes here,

130
00:06:14,200 --> 00:06:15,280
that's all we need.

131
00:06:15,280 --> 00:06:17,643
Because I just need some raw user data.

132
00:06:19,040 --> 00:06:21,040
Now, back in orders controller,

133
00:06:21,040 --> 00:06:24,030
we can therefore of course also import user

134
00:06:24,030 --> 00:06:27,083
by requiring models user model.

135
00:06:28,170 --> 00:06:30,340
And then here, in add order,

136
00:06:30,340 --> 00:06:32,740
we can convert this into an async function

137
00:06:33,740 --> 00:06:36,480
and then get our user document

138
00:06:36,480 --> 00:06:40,980
by using await user find by ID.

139
00:06:40,980 --> 00:06:43,260
And now the ID is something

140
00:06:43,260 --> 00:06:45,690
we get from res.locals, as you learned,

141
00:06:45,690 --> 00:06:46,713
res.locals.uid.

142
00:06:47,970 --> 00:06:51,263
That's a value we store in our check-auth middleware.

143
00:06:53,290 --> 00:06:55,520
Now, of course, this might fail, as always,

144
00:06:55,520 --> 00:07:00,050
so we want to wrap this with try-catch here,

145
00:07:00,050 --> 00:07:02,493
like this,

146
00:07:04,070 --> 00:07:06,860
and define the user document

147
00:07:06,860 --> 00:07:09,400
outside of that so that we can access it

148
00:07:09,400 --> 00:07:12,250
inside and outside of try.

149
00:07:12,250 --> 00:07:14,090
And here in the catch case, of course,

150
00:07:14,090 --> 00:07:18,213
we need next to return next here

151
00:07:19,650 --> 00:07:22,370
with that error, as we did it many times before,

152
00:07:22,370 --> 00:07:24,420
in the course for error handling,

153
00:07:24,420 --> 00:07:26,163
when using async await.

154
00:07:28,060 --> 00:07:30,510
Now we've got the user data

155
00:07:30,510 --> 00:07:32,120
and therefore, for this this order,

156
00:07:32,120 --> 00:07:34,370
we can pass our user document

157
00:07:34,370 --> 00:07:36,363
into this order constructor.

158
00:07:37,440 --> 00:07:39,620
And therefore, the data which we'll store

159
00:07:39,620 --> 00:07:42,470
for this order will be all the user data

160
00:07:42,470 --> 00:07:44,310
except for the password.

161
00:07:44,310 --> 00:07:45,760
It would have been hashed anyways,

162
00:07:45,760 --> 00:07:47,710
but still I don't want to save that.

163
00:07:47,710 --> 00:07:50,440
It simply does not matter for the order.

164
00:07:50,440 --> 00:07:52,660
But I will save the email, the ID,

165
00:07:52,660 --> 00:07:54,170
the name, and the address.

166
00:07:54,170 --> 00:07:55,873
And that is exactly what I want.

167
00:07:56,850 --> 00:07:58,410
Now, all the other data is fine

168
00:07:58,410 --> 00:08:00,550
and doesn't need to be set,

169
00:08:00,550 --> 00:08:03,250
and therefore now, with that new order created,

170
00:08:03,250 --> 00:08:07,393
we can call order.save to save it to the database.

171
00:08:08,800 --> 00:08:10,670
And just as before, this is something

172
00:08:10,670 --> 00:08:12,700
which we want to try-catch.

173
00:08:12,700 --> 00:08:14,310
Alternatively, we could move it

174
00:08:14,310 --> 00:08:17,290
into the already existing try-catch block,

175
00:08:17,290 --> 00:08:20,053
but here, I'll write a separate try-catch block,

176
00:08:20,930 --> 00:08:25,650
and also return or just run next error here

177
00:08:25,650 --> 00:08:27,710
if we have an error,

178
00:08:27,710 --> 00:08:29,760
and also await this here.

179
00:08:29,760 --> 00:08:33,000
And if we succeed, if we make it past this,

180
00:08:33,000 --> 00:08:38,000
then here, or alternative after try-catch,

181
00:08:38,210 --> 00:08:40,570
then we need to return in the catch case though,

182
00:08:40,570 --> 00:08:42,520
so that the other code doesn't execute

183
00:08:42,520 --> 00:08:44,280
if we have an error.

184
00:08:44,280 --> 00:08:49,010
Then here, I want to send a response

185
00:08:49,010 --> 00:08:53,263
and we could redirect to /orders,

186
00:08:54,200 --> 00:08:56,110
a route, which we doesn't support yet

187
00:08:56,110 --> 00:08:57,370
with a get request,

188
00:08:57,370 --> 00:08:59,770
but that is, of course, something we can change.

189
00:09:02,000 --> 00:09:04,550
Now, to see this flow in action,

190
00:09:04,550 --> 00:09:07,220
I will add a very basic orders view

191
00:09:07,220 --> 00:09:11,510
so that we can register a very basic get /orders route

192
00:09:11,510 --> 00:09:13,050
so that we can test this

193
00:09:13,050 --> 00:09:14,760
without running into errors

194
00:09:14,760 --> 00:09:16,263
when trying to redirect.

195
00:09:17,340 --> 00:09:20,730
So therefore, in the views, in the customer folder,

196
00:09:20,730 --> 00:09:23,940
here I'll create a new sub-folder, which I'll name orders.

197
00:09:23,940 --> 00:09:28,940
And in there, I'll add a all-orders.ejs file,

198
00:09:29,260 --> 00:09:31,660
and it will just grab all products,

199
00:09:31,660 --> 00:09:34,350
copy that content into all-orders,

200
00:09:34,350 --> 00:09:36,960
get rid of the product styles here,

201
00:09:36,960 --> 00:09:41,960
rename this to 'All Your Orders'.

202
00:09:42,350 --> 00:09:43,430
And in the main area,

203
00:09:43,430 --> 00:09:45,150
I'll get rid of the unordered list.

204
00:09:45,150 --> 00:09:46,790
And for the moment,

205
00:09:46,790 --> 00:09:50,207
I'll just say 'All Your Orders'.

206
00:09:52,000 --> 00:09:54,120
So that is a dummy orders template.

207
00:09:54,120 --> 00:09:55,623
We'll refine it later.

208
00:09:56,480 --> 00:09:58,240
Now we can add a controller action

209
00:09:58,240 --> 00:10:00,030
for getting those orders,

210
00:10:00,030 --> 00:10:01,313
may be at the top.

211
00:10:03,470 --> 00:10:06,550
Here, a function called getOrders,

212
00:10:06,550 --> 00:10:10,010
which at the moment will just render this dummy template.

213
00:10:10,010 --> 00:10:14,010
We'll fetch and render the concrete orders later.

214
00:10:14,010 --> 00:10:18,660
At the moment, I just render customer orders

215
00:10:18,660 --> 00:10:20,320
all-orders.

216
00:10:20,320 --> 00:10:22,820
That was the path to that template,

217
00:10:22,820 --> 00:10:25,053
to this EJS template we just added.

218
00:10:28,860 --> 00:10:31,500
Now we can export getOrders here

219
00:10:31,500 --> 00:10:34,223
to make it available outside of this file.

220
00:10:35,550 --> 00:10:38,493
And in the orders routes file,

221
00:10:39,630 --> 00:10:42,920
here, we can now register a new route,

222
00:10:42,920 --> 00:10:45,053
a get route to slash nothing,

223
00:10:46,100 --> 00:10:48,520
which is /orders, as you know,

224
00:10:48,520 --> 00:10:51,620
because we have this prefix in app.js.

225
00:10:51,620 --> 00:10:53,850
And here for this get request,

226
00:10:53,850 --> 00:10:57,273
I want to execute ordersController getOrders.

227
00:10:59,603 --> 00:11:00,940
Now that was a lot of work,

228
00:11:00,940 --> 00:11:03,480
but theoretically, we should now be able

229
00:11:03,480 --> 00:11:06,650
to save our cart data in the database

230
00:11:06,650 --> 00:11:08,073
when we click this button.

231
00:11:09,300 --> 00:11:11,920
So let's reload with a logged in user

232
00:11:11,920 --> 00:11:13,803
and let's click byproducts.

233
00:11:14,792 --> 00:11:15,940
And I get an error,

234
00:11:15,940 --> 00:11:19,420
total quantity can't be read here.

235
00:11:19,420 --> 00:11:24,420
This is actually coming from the 500 EJS template though.

236
00:11:24,620 --> 00:11:27,370
So it's tried to render that view

237
00:11:27,370 --> 00:11:30,020
and then failed to access total quantity.

238
00:11:30,020 --> 00:11:32,413
So we'll have to look into why that happened.

239
00:11:33,370 --> 00:11:36,460
But in the end, it failed to process this request

240
00:11:36,460 --> 00:11:39,200
and therefore it wanted to show 500 EJS

241
00:11:39,200 --> 00:11:41,580
because of a missing CSRF token,

242
00:11:41,580 --> 00:11:43,743
which indeed I did forget to add.

243
00:11:44,800 --> 00:11:47,300
We'll still have to check why the 500 page

244
00:11:47,300 --> 00:11:49,000
can't be rendered correctly,

245
00:11:49,000 --> 00:11:51,760
but to solve the issue of not submitting the orders

246
00:11:51,760 --> 00:11:55,950
successfully, we should go to cart.ejs,

247
00:11:55,950 --> 00:11:59,230
which is where I have this form for buying products.

248
00:11:59,230 --> 00:12:01,200
And there, we should add an input

249
00:12:02,090 --> 00:12:03,373
of type hidden,

250
00:12:04,230 --> 00:12:07,200
with a name of _csrf,

251
00:12:07,200 --> 00:12:11,730
where the value now is locals.csrfToken,

252
00:12:11,730 --> 00:12:13,653
as we did it many times before.

253
00:12:15,770 --> 00:12:17,650
With that, if we save this,

254
00:12:17,650 --> 00:12:19,540
and we reload this cart,

255
00:12:19,540 --> 00:12:21,610
if I click byproducts,

256
00:12:21,610 --> 00:12:23,830
now I'm redirected to the orders page.

257
00:12:23,830 --> 00:12:25,670
So this looks better.

258
00:12:25,670 --> 00:12:28,040
The cart is not emptied because we haven't added

259
00:12:28,040 --> 00:12:31,650
any logic for this, but we're on the orders page.

260
00:12:31,650 --> 00:12:33,060
And now let's see.

261
00:12:33,060 --> 00:12:35,250
If I use the Mongo shell here

262
00:12:35,250 --> 00:12:37,880
and I use my online shop database,

263
00:12:37,880 --> 00:12:40,019
if I now find all my orders,

264
00:12:40,019 --> 00:12:42,483
indeed there is some order data here.

265
00:12:43,690 --> 00:12:45,960
And what you can tell is that there

266
00:12:45,960 --> 00:12:48,190
I got my user data

267
00:12:48,190 --> 00:12:50,350
actually including the password.

268
00:12:50,350 --> 00:12:51,300
That should not happen.

269
00:12:51,300 --> 00:12:53,460
Let's check on this.

270
00:12:53,460 --> 00:12:55,630
But then all the other user data as well,

271
00:12:55,630 --> 00:12:58,150
and then the product data with all that cart data,

272
00:12:58,150 --> 00:12:59,690
which we had,

273
00:12:59,690 --> 00:13:02,760
which is all the product data,

274
00:13:02,760 --> 00:13:04,420
which we used before,

275
00:13:04,420 --> 00:13:07,540
and of course also the total quantity

276
00:13:07,540 --> 00:13:08,700
and total price,

277
00:13:08,700 --> 00:13:12,743
and then our time snapshot and this status.

278
00:13:14,090 --> 00:13:16,440
Now let's first fix the projection issue

279
00:13:16,440 --> 00:13:18,670
with the user password.

280
00:13:18,670 --> 00:13:23,170
For this, we can go back to the user model

281
00:13:23,170 --> 00:13:26,280
and there password should be set to zero.

282
00:13:26,280 --> 00:13:29,010
One would include it and then actually exclude

283
00:13:29,010 --> 00:13:31,500
all other files except for the ID.

284
00:13:31,500 --> 00:13:33,040
If you want to exclude password

285
00:13:33,040 --> 00:13:34,570
and include all other files,

286
00:13:34,570 --> 00:13:36,733
you don't set minus one but zero.

287
00:13:37,590 --> 00:13:38,870
And in addition,

288
00:13:38,870 --> 00:13:42,710
this also needs to go into a nested field here

289
00:13:42,710 --> 00:13:44,950
because when you use the findOne method

290
00:13:44,950 --> 00:13:47,640
of the Mongo DB Node JS driver,

291
00:13:47,640 --> 00:13:50,180
this second object, which we pass to it,

292
00:13:50,180 --> 00:13:52,880
is actually a configuration object,

293
00:13:52,880 --> 00:13:54,940
which has a projection key,

294
00:13:54,940 --> 00:13:56,750
and that then is the object

295
00:13:56,750 --> 00:13:59,830
with the concrete projection configuration.

296
00:13:59,830 --> 00:14:01,560
So it's this projection key,

297
00:14:01,560 --> 00:14:03,050
which holds the object,

298
00:14:03,050 --> 00:14:05,023
where I set password to zero.

299
00:14:06,480 --> 00:14:09,180
With that, if I go back to my orders

300
00:14:09,180 --> 00:14:12,210
and I actually delete the orders there

301
00:14:12,210 --> 00:14:15,600
with deleteMany and then an empty object,

302
00:14:15,600 --> 00:14:17,220
if we now go back to the cart

303
00:14:17,220 --> 00:14:19,670
and place this order again,

304
00:14:19,670 --> 00:14:23,210
and we now do get all orders again.

305
00:14:23,210 --> 00:14:25,280
Now in there, we don't find

306
00:14:25,280 --> 00:14:27,040
the user password anymore.

307
00:14:27,040 --> 00:14:28,433
So that's now fixed.

308
00:14:29,940 --> 00:14:34,230
So with that, we're storing this order data.

309
00:14:34,230 --> 00:14:36,090
Of course, what we're not doing yet

310
00:14:36,090 --> 00:14:38,190
is resetting the cart.

311
00:14:38,190 --> 00:14:39,640
Once we place the order,

312
00:14:39,640 --> 00:14:41,083
we want to clear the cart.

313
00:14:42,090 --> 00:14:46,040
So to achieve this in the orders controller,

314
00:14:46,040 --> 00:14:47,650
after we add the order,

315
00:14:47,650 --> 00:14:50,000
right before I redirect to orders,

316
00:14:50,000 --> 00:14:53,940
I actually want to go to request session

317
00:14:53,940 --> 00:14:57,570
and set my cart equal to null,

318
00:14:57,570 --> 00:14:59,820
to entirely reset it,

319
00:14:59,820 --> 00:15:03,070
to entirely clear it from the session.

320
00:15:03,070 --> 00:15:04,590
Because keep in mind, the cart

321
00:15:04,590 --> 00:15:06,310
is only stored in the session.

322
00:15:06,310 --> 00:15:07,820
So if we remove it from there,

323
00:15:07,820 --> 00:15:10,283
we clear all the data that belongs to it.

324
00:15:11,600 --> 00:15:15,660
Now, if we do that and we try placing the order again,

325
00:15:15,660 --> 00:15:18,023
therefore now the cart is reset here.

326
00:15:19,286 --> 00:15:20,500
And that's looking good.

327
00:15:20,500 --> 00:15:22,060
That's working the way it should.

328
00:15:22,060 --> 00:15:23,770
Now of course, we want to make sure

329
00:15:23,770 --> 00:15:25,690
that on this orders page,

330
00:15:25,690 --> 00:15:28,100
we also output all the orders

331
00:15:28,100 --> 00:15:31,450
that belong to this user who is logged in.

332
00:15:31,450 --> 00:15:32,610
And that's important.

333
00:15:32,610 --> 00:15:35,223
Only the orders that belong to this user.

