1 00:00:00,330 --> 00:00:07,580 So if you get nothing here in order to fix this problem, you can simply change the loop here in the 2 00:00:07,590 --> 00:00:11,580 calculate total order price from while two for each. 3 00:00:12,120 --> 00:00:20,400 So if I say here for each order details as the as or as wrong as row. 4 00:00:22,390 --> 00:00:25,750 Similarly with the loop below here. 5 00:00:26,080 --> 00:00:35,170 And instead of saying, while you need this, we need to save for each and then order details as or 6 00:00:35,170 --> 00:00:38,350 details as raw. 7 00:00:39,440 --> 00:00:42,440 Now if I save and go back to test. 8 00:00:43,600 --> 00:00:46,170 Let me refresh and click on details. 9 00:00:46,180 --> 00:00:48,790 As you can see, it's going to display the orders and we have no problem. 10 00:00:49,120 --> 00:00:57,160 Now, if you click on pay, now, we will have here a very big problem, which is the collision between 11 00:00:57,640 --> 00:00:59,640 the session and the order detail. 12 00:00:59,650 --> 00:01:03,040 So here it says total payment is is nothing. 13 00:01:03,040 --> 00:01:04,540 And then it says that you don't have order. 14 00:01:04,540 --> 00:01:06,070 And then here it says not not me. 15 00:01:06,070 --> 00:01:06,850 So we have a problem. 16 00:01:07,300 --> 00:01:12,730 To fix this problem, we need to establish a strong logic here. 17 00:01:13,060 --> 00:01:19,810 So here, in order to do to do this, we need to re revisit our code here. 18 00:01:19,810 --> 00:01:25,780 And to do this I'm going to open a BGP script and then I'm going to say, firstly, if, if. 19 00:01:26,690 --> 00:01:28,820 Is sex. 20 00:01:29,820 --> 00:01:41,160 And then session if the session total if we have something in the session and and that session total 21 00:01:42,390 --> 00:01:48,930 session total is not total is not equal to zero or is not empty. 22 00:01:49,710 --> 00:01:55,860 It's not if it's not empty, you can say not empty or not equal to zero, then what we need to do is 23 00:01:55,860 --> 00:01:57,860 that we need to display this total amount. 24 00:01:57,870 --> 00:02:00,660 I'm going to copy this line of every. 25 00:02:00,660 --> 00:02:01,080 Move it. 26 00:02:02,320 --> 00:02:02,610 I'm going. 27 00:02:02,620 --> 00:02:03,490 I'm going to sit here. 28 00:02:04,950 --> 00:02:10,720 And then we to remove all this because we already displayed here. 29 00:02:10,740 --> 00:02:12,120 Let me remove all of this. 30 00:02:13,390 --> 00:02:16,210 And here we just need to say. 31 00:02:20,740 --> 00:02:24,250 A year when you say BHP. 32 00:02:26,560 --> 00:02:27,550 BHP. 33 00:02:30,120 --> 00:02:31,020 And then echo. 34 00:02:32,600 --> 00:02:33,170 Decision. 35 00:02:33,190 --> 00:02:41,980 Decision and then we just need to clause here, let me type this from the beginning. 36 00:02:43,450 --> 00:02:45,210 And then here semicolon. 37 00:02:45,760 --> 00:02:47,320 And then we need to close the HP. 38 00:02:48,390 --> 00:02:52,440 And then here we need to say it should be like this. 39 00:02:53,470 --> 00:02:56,670 So this is in case in case the session is not empty. 40 00:02:56,680 --> 00:03:00,160 And in case we have a session, we have something in session. 41 00:03:00,170 --> 00:03:00,580 But. 42 00:03:02,180 --> 00:03:08,740 But we need to remove this code completely now and we need to display the button. 43 00:03:08,750 --> 00:03:10,460 We need also to display the button here. 44 00:03:11,060 --> 00:03:12,740 He went to display the button like this. 45 00:03:13,130 --> 00:03:18,800 So in case the session is total, is not empty, and there is something and the total is not zero, 46 00:03:18,800 --> 00:03:27,050 then we need to display the pay button else if we need to save BHP, maybe add this in a new line BHP 47 00:03:27,050 --> 00:03:28,670 and then if. 48 00:03:29,820 --> 00:03:35,650 If is set a set boast. 49 00:03:37,200 --> 00:03:37,740 Lost. 50 00:03:39,840 --> 00:03:40,380 Order. 51 00:03:40,410 --> 00:03:42,330 Status, order. 52 00:03:42,330 --> 00:03:51,450 Underscore status and and order status based order status. 53 00:03:55,250 --> 00:03:56,330 Is not equal. 54 00:03:59,400 --> 00:04:03,300 Is if it's sit and it's equal to not paid. 55 00:04:04,020 --> 00:04:05,700 Not paid. 56 00:04:07,230 --> 00:04:10,150 Then we need to say here, we need to open bracket. 57 00:04:10,950 --> 00:04:14,700 And here, by the way, we need to close the Kaylie bracket, maybe say Peachtree and then maybe close 58 00:04:14,700 --> 00:04:15,540 the bracket. 59 00:04:17,960 --> 00:04:19,670 And this is the first statement. 60 00:04:21,150 --> 00:04:21,540 Here. 61 00:04:22,170 --> 00:04:24,370 And then he by the way, we need to say ill. 62 00:04:24,400 --> 00:04:30,530 So I'm going to say who else if because this this is a continuation of the previous cuts. 63 00:04:30,690 --> 00:04:35,420 We need to say actually we need to close the Kennelly bracket here and we need to remove this completely. 64 00:04:35,460 --> 00:04:36,600 We can remove this now. 65 00:04:37,050 --> 00:04:45,060 So it's going to say here else if if the order is the status is not is set and it's it's not paid, 66 00:04:45,570 --> 00:04:50,220 then we need to close that up and then we you to get this. 67 00:04:50,220 --> 00:04:50,550 Good. 68 00:04:51,030 --> 00:04:52,140 Let me get this good. 69 00:04:54,140 --> 00:04:57,020 And then let me pace with here and let me push it. 70 00:04:57,740 --> 00:05:03,200 So here we need to display we need to say if we need we don't need this now. 71 00:05:03,200 --> 00:05:08,960 We just need to display the button and we need to display the be here when it is AP. 72 00:05:10,340 --> 00:05:12,890 And then total payment. 73 00:05:17,670 --> 00:05:19,560 And then he should be. 74 00:05:21,110 --> 00:05:21,860 And then. 75 00:05:24,750 --> 00:05:25,350 Echo. 76 00:05:27,430 --> 00:05:28,000 Bost. 77 00:05:30,580 --> 00:05:31,210 Order. 78 00:05:32,280 --> 00:05:34,180 Go tell Price. 79 00:05:36,040 --> 00:05:37,000 And then semi-colon. 80 00:05:37,390 --> 00:05:39,400 And don't forget to close the attack. 81 00:05:41,080 --> 00:05:42,890 And finally, I'm going to close the year. 82 00:05:42,910 --> 00:05:47,560 I'm going to say I'm going to say you're BHP. 83 00:05:50,170 --> 00:05:54,100 And then else else. 84 00:05:55,770 --> 00:06:04,010 Else if if if we don't have if the court is empty and if the order is also empty, if if the U.S. doesn't 85 00:06:04,020 --> 00:06:10,800 doesn't have that order, then we need to take the user to another page or we can display an error message. 86 00:06:12,030 --> 00:06:15,630 We can use HP and then close the candy brackets. 87 00:06:16,560 --> 00:06:19,260 And you also close the candy bracket. 88 00:06:20,320 --> 00:06:22,440 It was the HP actually. 89 00:06:22,830 --> 00:06:28,110 And in between you need to display either an error message or or take the user to another page. 90 00:06:28,110 --> 00:06:32,220 So let me copy this message and then I'm going to say here, you don't have an order. 91 00:06:32,220 --> 00:06:32,700 That's it. 92 00:06:33,030 --> 00:06:34,080 Just you don't have an order. 93 00:06:36,520 --> 00:06:38,620 So let me walk you through the code one more time. 94 00:06:39,040 --> 00:06:40,930 So now we don't need any of this. 95 00:06:40,940 --> 00:06:42,280 We need to remove all of this. 96 00:06:42,730 --> 00:06:43,990 Let me now walk you through this. 97 00:06:44,320 --> 00:06:51,160 So this logic now is very, very clear and well established here in case in case we have something in 98 00:06:51,160 --> 00:06:51,580 the cart. 99 00:06:52,030 --> 00:06:53,440 The first thing you check is the cart. 100 00:06:53,710 --> 00:06:59,740 If something is a cart and if they can't do it, if the total is set, which means that there is something 101 00:06:59,740 --> 00:07:04,630 in the cart, and if that total is not zero, then there is something in the cart. 102 00:07:04,630 --> 00:07:09,910 And we need to display the P button and we need to display the total amount that the user wants to pay 103 00:07:10,690 --> 00:07:12,310 and should pay in order to get the product. 104 00:07:12,790 --> 00:07:20,530 And else if if the total if the session is empty, if the user didn't add anything in the cart, then 105 00:07:20,530 --> 00:07:25,930 he went to check if the user came to this page by clicking on. 106 00:07:26,080 --> 00:07:29,020 By clicking on this button by clicking on. 107 00:07:30,060 --> 00:07:36,330 Mike by checking one of the orders, the old orders, and clicking on one of these bay buttons. 108 00:07:36,840 --> 00:07:42,210 So if that's true, then we need to display the payment and we also need to display the total amount 109 00:07:42,210 --> 00:07:44,730 that they should pay else. 110 00:07:45,090 --> 00:07:48,120 If neither of these is correct, then we need to display. 111 00:07:48,120 --> 00:07:49,200 You don't have an order. 112 00:07:50,250 --> 00:07:50,980 Pretty simple. 113 00:07:51,000 --> 00:07:51,600 Now let me say. 114 00:07:51,600 --> 00:07:53,040 Well, let's test now. 115 00:07:53,370 --> 00:07:55,770 Now, let me go back at this from the beginning. 116 00:07:55,770 --> 00:07:58,710 So let me refresh and click on details. 117 00:07:59,340 --> 00:08:01,650 And now if you click on pay now. 118 00:08:03,140 --> 00:08:03,430 Here. 119 00:08:03,440 --> 00:08:09,890 It's going to display the total amount and it's going to split the paper by now and let's test the other 120 00:08:09,890 --> 00:08:10,280 one. 121 00:08:10,280 --> 00:08:16,070 So the total is correct, by the way, 155 plus 250, the total is 405. 122 00:08:16,070 --> 00:08:16,910 So that's correct. 123 00:08:17,420 --> 00:08:20,510 Let's test another order just to make sure that everything everything is fine. 124 00:08:20,510 --> 00:08:21,680 So limit this this order. 125 00:08:22,130 --> 00:08:23,600 So this order is 150. 126 00:08:23,600 --> 00:08:28,790 If I click on pay now, it's going to here display 150 and here it says Pay now. 127 00:08:29,180 --> 00:08:31,520 Now, let me add something to the card. 128 00:08:31,520 --> 00:08:34,220 Silly me, go to the card and the card now is empty. 129 00:08:34,580 --> 00:08:39,800 So if I go to the homepage and add something to the card, for example, Amy, add this product, I'm 130 00:08:39,800 --> 00:08:42,590 going to add this product by now. 131 00:08:43,010 --> 00:08:45,890 And now the card has only one product. 132 00:08:45,890 --> 00:08:49,490 If I click on, check out and let me fill out this form. 133 00:08:49,910 --> 00:08:55,940 So if I fill out this form and click on place order, as you can see, it's going to display the 149 134 00:08:56,120 --> 00:09:00,770 and pay now, but only once, because now this card works perfectly. 135 00:09:00,770 --> 00:09:06,470 It's going to check for the card if the card is empty, if the card is not empty, like this case, 136 00:09:06,620 --> 00:09:11,500 like in this case, it's going to display the button and the total il6. 137 00:09:11,810 --> 00:09:15,050 If it's empty, then it's going to check the order status. 138 00:09:15,050 --> 00:09:21,260 If the user came to this page via the via their account else is just going to display. 139 00:09:21,560 --> 00:09:22,550 Don't have an order. 140 00:09:22,550 --> 00:09:23,990 Let me prove it to you. 141 00:09:24,000 --> 00:09:29,570 Now, if I go to the card and remove everything from the card, let me remove everything from the card 142 00:09:30,020 --> 00:09:31,570 and let me go to the payment page. 143 00:09:31,580 --> 00:09:37,670 Now, if I go to the payment limit here, say payment got between here, it should display an error 144 00:09:37,670 --> 00:09:38,000 message. 145 00:09:38,000 --> 00:09:40,670 As you can see, it's going to say you don't have an error. 146 00:09:40,670 --> 00:09:41,690 It's not an error message. 147 00:09:41,690 --> 00:09:42,470 It's just a message. 148 00:09:42,500 --> 00:09:43,370 You don't have an error. 149 00:09:43,940 --> 00:09:46,220 So you're going to have you're going to have an order. 150 00:09:46,790 --> 00:09:47,990 So it works successfully. 151 00:09:47,990 --> 00:09:55,010 And now our payment page is perfect and we can proceed to the next step, which is handling payments.