1 00:00:00,420 --> 00:00:01,080 Welcome back. 2 00:00:01,500 --> 00:00:06,240 Now, what we need to do is that we need to work on the statement where if you there has already added 3 00:00:06,240 --> 00:00:07,200 something to the card. 4 00:00:07,560 --> 00:00:10,260 So if you use our has ADD, it has already added something to the cart. 5 00:00:10,710 --> 00:00:18,630 We need to to check whether the new product is one of the products that the user has already added to 6 00:00:18,630 --> 00:00:19,380 the cart or not. 7 00:00:19,950 --> 00:00:23,940 To do this, we need to create a new variable called product. 8 00:00:25,200 --> 00:00:30,750 Products are products under score array. 9 00:00:31,920 --> 00:00:40,950 Ideas which is going to return and an array with all products that are with or with all product ideas 10 00:00:40,950 --> 00:00:43,650 that have been added to the to the cart. 11 00:00:44,070 --> 00:00:47,550 And that can be done using the array column function. 12 00:00:48,030 --> 00:00:53,460 If I see a recall and if I pass the session to it session cart. 13 00:00:55,190 --> 00:00:55,970 Efficient car. 14 00:00:57,260 --> 00:01:02,840 And then if I pass the column that I'm interested in to the column is the product A-D. 15 00:01:03,290 --> 00:01:05,980 I'm going to say product maybe. 16 00:01:11,120 --> 00:01:18,940 This is going to return an array with all products, with all products, products, products, ads. 17 00:01:19,400 --> 00:01:27,710 So for example, if I added product, product that has an idea of two and three and four and ten and 18 00:01:27,710 --> 00:01:28,370 15. 19 00:01:28,700 --> 00:01:32,510 Then this array is going to return is going to return these items. 20 00:01:33,470 --> 00:01:38,870 And then we need to use this statement to check whether the product has already been added or not. 21 00:01:39,380 --> 00:01:45,920 So I'm going to say if if that product is not in the array, if in array. 22 00:01:46,820 --> 00:01:47,870 If an array. 23 00:01:48,840 --> 00:01:51,570 And then if in a array. 24 00:01:54,740 --> 00:01:55,070 If. 25 00:01:55,440 --> 00:01:57,230 If it's not in the array. 26 00:01:58,490 --> 00:01:59,210 The product. 27 00:01:59,210 --> 00:02:00,500 The product. 28 00:02:00,500 --> 00:02:00,680 It. 29 00:02:03,780 --> 00:02:03,950 Right. 30 00:02:04,260 --> 00:02:04,440 If. 31 00:02:11,070 --> 00:02:11,970 Comma and then. 32 00:02:14,380 --> 00:02:17,050 Product, products and rides. 33 00:02:18,860 --> 00:02:19,790 Let me explain this. 34 00:02:20,480 --> 00:02:22,850 I'm going to have your Kelly brackets. 35 00:02:23,210 --> 00:02:35,030 So this is going to check this statement is going to check if a product has already been added or not 36 00:02:35,540 --> 00:02:37,550 added to cart or not. 37 00:02:39,590 --> 00:02:47,660 How by by comparing this function in array is going to compare is going to try to find if this product 38 00:02:47,730 --> 00:02:55,340 it is is one of the product array it is one of the elements of the product's array IDs. 39 00:02:55,670 --> 00:03:05,660 So if that ID exists within exists in this are in this products array IDs, then we need to tell the 40 00:03:05,660 --> 00:03:18,470 user here to say here in this case product has already been at it's been at l a here. 41 00:03:18,890 --> 00:03:20,980 If not, then we need to add it to a card. 42 00:03:20,990 --> 00:03:27,260 So here, here in this, if we need to add it to the card and to add that to the card, we need to create 43 00:03:27,260 --> 00:03:27,620 another. 44 00:03:27,620 --> 00:03:30,890 We need to get an array like this. 45 00:03:31,190 --> 00:03:40,610 We need to we need to create a code like this and add that to the to the to the session to the session 46 00:03:40,610 --> 00:03:40,880 card. 47 00:03:40,880 --> 00:03:42,080 So I'm going to copy this card. 48 00:03:44,250 --> 00:03:44,520 And mean. 49 00:03:44,540 --> 00:03:45,720 I've got a business card here. 50 00:03:48,140 --> 00:03:51,110 I'm going to paste this code here, but I'm going to fix a few things. 51 00:03:51,740 --> 00:03:56,120 Let me push this and then I'm going to fix a few things. 52 00:03:56,450 --> 00:03:59,210 First, we need to say product ID is equal to the ID. 53 00:03:59,330 --> 00:04:00,020 That's fine. 54 00:04:00,620 --> 00:04:05,780 And then we need to pass these here in this array, this also fine. 55 00:04:06,350 --> 00:04:08,150 And finally, we need to have this array. 56 00:04:08,150 --> 00:04:09,120 So there isn't nothing. 57 00:04:09,140 --> 00:04:10,130 Nothing is going to be different. 58 00:04:10,580 --> 00:04:16,850 But instead of creating this long code, we can, for the sake of making everything simple, we can 59 00:04:16,850 --> 00:04:17,210 push. 60 00:04:17,210 --> 00:04:23,300 We can insert the past, the past parameters immediately. 61 00:04:23,300 --> 00:04:30,410 So we can say your product, product, underscore ID immediately without creating these parameters. 62 00:04:31,070 --> 00:04:34,730 So without using these parameters, because it's just going to take more code. 63 00:04:34,730 --> 00:04:40,790 If you don't want to do this, you can use the POS request immediately like this. 64 00:04:48,650 --> 00:04:53,540 This is just going to reduce the number of number of lines we have in our. 65 00:05:19,320 --> 00:05:24,750 So as you can see here, I removed these lines and now our code is much smaller. 66 00:05:25,050 --> 00:05:31,830 Much shorter now for for in case the user has already added this product to cart, we need to tell them. 67 00:05:31,830 --> 00:05:33,600 We need to say, for example, echo. 68 00:05:36,310 --> 00:05:36,850 Echo. 69 00:05:39,930 --> 00:05:40,440 Script.