1 00:00:01,170 --> 00:00:01,800 Welcome back. 2 00:00:02,160 --> 00:00:04,890 Now, what we need to do is that we need to work on this edit button. 3 00:00:05,190 --> 00:00:12,390 So if a user decides to increase the quantity of a product, we need to edit the quantity and the subtotal. 4 00:00:12,420 --> 00:00:18,510 So if the user clicks here on edit and chooses, for example, for quantity, for items of the same 5 00:00:18,510 --> 00:00:22,030 product, we need to increase the quantity as well as the subtotal. 6 00:00:22,050 --> 00:00:22,830 How can we do this? 7 00:00:23,460 --> 00:00:27,060 To do this, we need to activate this button. 8 00:00:27,510 --> 00:00:30,660 So remember here in the cart, we have this edit button. 9 00:00:31,260 --> 00:00:37,770 We need to create a form here where you could say form and then this form we're going to give it method 10 00:00:37,770 --> 00:00:38,160 and action. 11 00:00:38,160 --> 00:00:45,780 So the method is going to be fast and the action is going to be cart, dot, HP. 12 00:00:46,650 --> 00:00:51,480 And then I'm going to move I'm going to remove this attack. 13 00:00:51,480 --> 00:00:57,480 And then I'm going to create here two inputs, one input, and I'm going to give it a class called edit 14 00:00:57,480 --> 00:01:01,290 button, edit button and values. 15 00:01:01,290 --> 00:01:01,980 So the value. 16 00:01:03,960 --> 00:01:05,070 Value is at it. 17 00:01:06,330 --> 00:01:07,530 And also we need name. 18 00:01:07,920 --> 00:01:11,070 So the name is added quantity. 19 00:01:11,970 --> 00:01:14,930 Added underscore quantity. 20 00:01:16,800 --> 00:01:21,450 And we need another input, which is the product, the input. 21 00:01:22,740 --> 00:01:25,070 And then name first type. 22 00:01:25,080 --> 00:01:30,960 The type is hidden and the name is product I.D.. 23 00:01:32,920 --> 00:01:35,890 And the value is between. 24 00:01:37,440 --> 00:01:37,950 Echo. 25 00:01:39,570 --> 00:01:42,060 Product value. 26 00:01:42,060 --> 00:01:44,310 Product value. 27 00:01:46,360 --> 00:01:47,020 Product. 28 00:01:48,620 --> 00:01:52,370 Product I.D. semicolon. 29 00:01:53,270 --> 00:01:57,470 And don't forget to close this angular bracket. 30 00:01:57,860 --> 00:02:01,970 And here the second input must have a type, and the type is submit. 31 00:02:03,540 --> 00:02:04,620 Let me push these to. 32 00:02:06,630 --> 00:02:08,460 And again, let me explain this one more time. 33 00:02:08,880 --> 00:02:16,410 This form is inside this loop so we can use the value, the product ID value, and the second input 34 00:02:17,280 --> 00:02:22,140 and the first input is hidden, but it's going to hold the product ID, the second input is going to 35 00:02:22,140 --> 00:02:29,430 submit the form and it will allow us to get the product ID and edit the quantity. 36 00:02:30,120 --> 00:02:33,300 So we also need the right quantity itself. 37 00:02:33,900 --> 00:02:35,340 So we need to create another. 38 00:02:36,030 --> 00:02:39,510 We need to create another input for the quantity itself. 39 00:02:40,380 --> 00:02:43,020 Remember, the quantity is is this. 40 00:02:44,150 --> 00:02:45,800 So we need you to yet another input. 41 00:02:45,870 --> 00:02:53,180 I'm going to say your book or actually we have the way the input we need to copy it and then we need 42 00:02:53,180 --> 00:02:56,840 to move it over to the form so it's going to be here. 43 00:02:57,110 --> 00:02:59,990 So this is the quantity Laney save and. 44 00:03:00,990 --> 00:03:04,740 Let's this let's make sure that the female code is not broken. 45 00:03:05,880 --> 00:03:11,100 So as you can see, it's fine, but we need to do fix the edit. 46 00:03:11,670 --> 00:03:13,200 So we need to remove the again. 47 00:03:13,200 --> 00:03:14,640 We need to return over to CSIS. 48 00:03:15,330 --> 00:03:16,890 And we need to edit the. 49 00:03:17,430 --> 00:03:19,440 We need to open the style. 50 00:03:19,440 --> 00:03:19,980 Let's use this. 51 00:03:20,520 --> 00:03:27,570 And then for the edit button, we need to hear, say, background color white. 52 00:03:31,010 --> 00:03:34,700 And we need to remove the borders or none. 53 00:03:35,780 --> 00:03:37,700 And the width is 100%. 54 00:03:41,450 --> 00:03:42,080 Lady save on. 55 00:03:42,080 --> 00:03:44,150 Let me make sure that they resign is fine. 56 00:03:46,970 --> 00:03:48,770 So let me go back to the page. 57 00:03:52,170 --> 00:03:55,950 So in the garbage we have, we now we have actually a problem. 58 00:03:55,950 --> 00:03:58,340 So let me remove this weight. 59 00:03:58,350 --> 00:04:01,830 I don't think that the with is needed here. 60 00:04:03,850 --> 00:04:07,210 So again, I need to go to the cart one more time. 61 00:04:08,970 --> 00:04:09,860 They should fix it. 62 00:04:10,220 --> 00:04:11,300 So it has been fixed. 63 00:04:11,750 --> 00:04:13,520 Now we need to work on the logic. 64 00:04:14,000 --> 00:04:18,890 So here we need to create in every car that BHP. 65 00:04:19,460 --> 00:04:25,730 What we want to do is that we need to use the these inputs and use the past 66 00:04:28,280 --> 00:04:29,690 value of BHP. 67 00:04:30,110 --> 00:04:32,150 So at the top we need to add else. 68 00:04:32,150 --> 00:04:37,610 If with this else, if we need to push this good, then we need to create another elseif. 69 00:04:38,360 --> 00:04:39,080 ElseIf. 70 00:04:43,100 --> 00:04:48,830 And then don't forget to close the curly bracket and open it here and here. 71 00:04:48,830 --> 00:04:51,560 I'm going to say elseif if it's set. 72 00:04:52,650 --> 00:04:53,130 Lost. 73 00:04:54,990 --> 00:04:58,110 Lost and then a great quantity. 74 00:04:58,380 --> 00:05:00,390 It it quantity. 75 00:05:01,690 --> 00:05:02,160 Why? 76 00:05:02,730 --> 00:05:03,720 Why it quantity? 77 00:05:03,720 --> 00:05:05,250 Why do they say it is quantity? 78 00:05:05,250 --> 00:05:05,790 Because. 79 00:05:07,100 --> 00:05:07,460 Here. 80 00:05:08,210 --> 00:05:09,380 The forum has it. 81 00:05:09,380 --> 00:05:11,480 It wanted to submit the button. 82 00:05:11,480 --> 00:05:14,810 So the submit button has any called it is quantity. 83 00:05:14,810 --> 00:05:16,670 So we need to use this to submit the form. 84 00:05:19,320 --> 00:05:21,300 And here we need to work on their logic. 85 00:05:21,310 --> 00:05:26,070 So here's what we need to do, is that we need to get the current quantity and it is that quantity. 86 00:05:26,070 --> 00:05:27,660 So how can we get the current quantity? 87 00:05:28,170 --> 00:05:35,190 To get the current quantity we need to say here we need first to get the quantity from before. 88 00:05:35,190 --> 00:05:35,850 So I'm going to say. 89 00:05:39,160 --> 00:05:39,910 Your product. 90 00:05:40,540 --> 00:05:41,200 Product. 91 00:05:42,290 --> 00:05:47,990 Product underscore quantity is equal to cost. 92 00:05:49,480 --> 00:05:49,900 Boss. 93 00:05:51,580 --> 00:05:52,750 And then product quantity. 94 00:05:52,750 --> 00:05:59,770 Remember the form has product this for the product quantity it doesn't have a name. 95 00:05:59,770 --> 00:06:07,390 So we need to give it a name and the name is going to be equal to product quantity. 96 00:06:09,290 --> 00:06:12,420 So we need the product quantity and the product me from this form. 97 00:06:13,310 --> 00:06:20,630 So I'm going to say your product quantity is equal to past product underscore quantity. 98 00:06:21,590 --> 00:06:22,910 And then we need the product ID. 99 00:06:23,060 --> 00:06:29,650 So I'm going to get another variable called product ID and it's going to be equal to boss. 100 00:06:30,260 --> 00:06:30,440 Right. 101 00:06:30,530 --> 00:06:30,800 Okay. 102 00:06:34,220 --> 00:06:35,150 First and then. 103 00:06:38,200 --> 00:06:38,760 Product. 104 00:06:39,880 --> 00:06:40,210 I'd. 105 00:06:42,750 --> 00:06:46,950 Now we need to access the decision and update the product quantity. 106 00:06:47,400 --> 00:06:59,180 So to access the session, we can say session, event card and then we need to get the the product that 107 00:06:59,610 --> 00:07:01,230 the array of that specific product. 108 00:07:01,230 --> 00:07:02,190 So we need to say product. 109 00:07:02,970 --> 00:07:04,870 So this is going to return an array here. 110 00:07:04,890 --> 00:07:06,990 I'm going to say product. 111 00:07:08,710 --> 00:07:10,330 Product underscore at right. 112 00:07:11,410 --> 00:07:16,180 So the product array is equal to is equal to the session card product. 113 00:07:17,110 --> 00:07:24,010 Now from this product array, we can access the quantity, the current quantity, the old quantity. 114 00:07:24,310 --> 00:07:29,260 So can I say product underscore quantity. 115 00:07:29,590 --> 00:07:30,790 Quantity. 116 00:07:32,170 --> 00:07:34,450 This now is the old quantity. 117 00:07:34,930 --> 00:07:38,520 This is the old underscore quantity. 118 00:07:39,310 --> 00:07:40,920 And the new quantity is this. 119 00:07:40,930 --> 00:07:42,220 This is the new quantity. 120 00:07:42,910 --> 00:07:48,120 So instead, we need to replace we need to remove this old quantity and add the new quantity. 121 00:07:48,130 --> 00:07:49,030 How can we do this? 122 00:07:49,780 --> 00:07:53,820 To do this, we need to say we need 3 to 3. 123 00:07:53,830 --> 00:08:02,140 We need the we don't need this, this, this valuable like it is valuable just to explain how it works. 124 00:08:02,680 --> 00:08:08,050 All we need to do now is to say, right, the quantity is equal to the new product quantity, which 125 00:08:08,050 --> 00:08:10,690 is this product quantity. 126 00:08:12,540 --> 00:08:15,480 So this is the old the old quantity. 127 00:08:15,660 --> 00:08:18,720 I'm going to override the value with a new quantity. 128 00:08:19,140 --> 00:08:24,700 Finally, we need to push or add this array again to the to the session. 129 00:08:24,720 --> 00:08:25,980 So we need to say session. 130 00:08:27,850 --> 00:08:28,780 And then Garth. 131 00:08:34,640 --> 00:08:35,300 And then. 132 00:08:37,610 --> 00:08:37,940 And then. 133 00:08:37,940 --> 00:08:38,510 Product ID. 134 00:08:40,980 --> 00:08:41,790 Product ID. 135 00:08:43,470 --> 00:08:45,870 Is equal to the rate. 136 00:08:46,470 --> 00:08:47,490 So we need. 137 00:08:48,150 --> 00:08:50,590 We need we need to. 138 00:08:50,590 --> 00:08:57,350 To return the product array back to the to the to the decision. 139 00:08:57,960 --> 00:09:00,300 So let me explain this code one more time here. 140 00:09:00,600 --> 00:09:01,860 I'm going to add comments here. 141 00:09:01,890 --> 00:09:09,870 First get we get ID and quantity from before. 142 00:09:12,990 --> 00:09:22,560 And then the second step is to get the product array from the station. 143 00:09:22,560 --> 00:09:28,740 We extract that array, we extract out the array from the session because there might be many products. 144 00:09:29,280 --> 00:09:36,960 The third step is to update, update product quantity. 145 00:09:38,400 --> 00:09:45,030 The last step is to put back to a return or or return. 146 00:09:45,030 --> 00:09:48,720 That's a return array back to its place. 147 00:09:48,720 --> 00:09:53,460 To its place inside the session place. 148 00:09:54,240 --> 00:09:55,710 Let me save and let's test this. 149 00:09:55,710 --> 00:09:55,950 Good. 150 00:09:56,520 --> 00:10:01,970 So we're going to here refresh and then I'm going to try to increase it. 151 00:10:01,990 --> 00:10:06,030 I'm going to try to increase this value to, let's say three and then I'm going to click on edit. 152 00:10:07,080 --> 00:10:10,140 So as you can see, if I click on edit, now we have three. 153 00:10:10,620 --> 00:10:16,170 If I increase this to seven and if you click on edit, if we're going to say edit, it's going to say 154 00:10:16,170 --> 00:10:16,740 seven here. 155 00:10:17,850 --> 00:10:25,290 So it worked successfully, and now this product will be usable by seven items. 156 00:10:25,650 --> 00:10:29,640 If you want to make sure that it works, you can go back to the homepage. 157 00:10:29,640 --> 00:10:32,400 For example, you can go to the homepage. 158 00:10:34,450 --> 00:10:39,130 And then you can try to go back to let me go back to the cartridge. 159 00:10:39,550 --> 00:10:44,080 So if they try to go to the page one more time, it's going to it's going to remain here seven because 160 00:10:44,080 --> 00:10:47,680 now the user has set the number to save it. 161 00:10:48,220 --> 00:10:51,130 The next thing that we need to work on is the subtotal. 162 00:10:51,140 --> 00:10:53,170 So we need to work on this later.