Welcome back.
So now let's continue working on the placing an order feature.
So I told you that the first step is to get info and store stories in a database.
So this is the step.
This is getting the info.
The second step is to get products from Garth.
And this this this step is this gets products from from Garth, which is this.
And then the third step is to issue new order and store order info in database.
We've already done this.
Let me copy this comment and added in the right place.
So this is the this is the this is the line that is going to issue or get this is going to get the order
from the database and storing the order is this this line of code is going to insert the order into
the database.
So the second step, let's say your second step is to issue a new order.
The third step is to get products from the cart.
I'm going to say here three.
And then the fourth step is to store each single item in an order, the orders table.
We have done that.
Lady, copy this, lady, copy this.
This comment added in the right place.
So this line of good, this line of code is going to issue a new order and store and not this one.
Actually this one.
This one store made me copy it.
Store.
This line of code this line of code is going to store each single item in item table.
And this is getting the data from the session.
And the fourth.
The fifth is to remove everything from the cart.
And this this step should be delayed for now because we need to remove everything from the cart.
Only after user makes a after you as a completes payment.
So I'm going to say you delay the delay.
Until payment.
He's done.
So it's up to you if you want to delete everything from the card.
You can do that.
But I wouldn't recommend doing that because the user has not paid yet.
After user completes payment, we can remove everything from the card and finally is to inform user
whether everything is fine or not.
And if everything's fine.
Which.
In this.
In this case, everything is fine.
We need to take the user to the payment page.
So the fifth step is to remove everything from card.
I'm going to delay this.
However, if you want to, to delete everything from the card, you can use the on set function.
You can use the unset and then pass the session.
Session and then card is as we move everything from the cards like this, this line of code.
Very, very simple.
However, again, I wouldn't recommend doing that.
So I'm going to keep this card like here.
I'm going to keep this code right here, and I'm not going to remove everything from the card and they'll
use a complete statement.
And here the sixth step is to inform user whether a payment was successful or not and take user to the
to the payment page.
So in order to take the user to a payment page, we need to use the header.
Hey there.
Location.
Hey, they're on location and then the payment page.
So I'm going to create a page called.
Payment.
That BHP.
And I'm going to attach here a, I guess parameter.
I'm going to say order.
Start us.
Is equal to.
Order.
Least.
Successfully.
And you can add this good in if statement after you check after you check this excuse, you can do this
or you can leave it here because if something went wrong, the code will will essentially break and
the rest will not be executed.
So if something goes wrong, we we can we can use if statement with this excuse, for example, we can
say if something goes wrong here at this point.
We can we if if this is wrong, if this is false, we can take the user to another place.
But I'm not going to I'm not going to complicate because for now, I'm going to keep the code very simple.
And then later we can add more code as we move on.
So this step is to take the user to the payments page with this parameter.
So we need to display the payment button so that the user can complete the payment.
So I'm going to create a new page here called Payment.
That HP.
And the code for this page is going to be very similar to other pages.
For example, it's going to be similar to the checkout, but I'm not going to display anything but a
button just about in with the payment information.
So I'm going to copy the code from the checkout page and then I'm going to paste it into the payment
that me and in the payment that BGP.
What I'm going to do is that first I'm going to close down this filter because I'm not going to work
on the filter that is going to be the same.
And I'm going to close down also the navigation bar.
And in between, we have the check out.
Instead of check out, I'm going to say payment, payment.
And here I'm going to remove many things.
So I'm going to remove I'm going to remove this for actually, we we just need to remove this for I'm
going to remove this form.
For now and I'm just going to display here payment.
Be.
Ment.
And here in this dance, I'm just going to say I'm just going to say B and then I'm going to display
the total.
I can't remember the total amount is stored again is stored in the session.
So, so here I'm going to say Echo and then I'm going to echo the session.
I'm going to say Echo and then session.
And what do we want to.
We want to equity.
Total.
Total amount.
I'm going to take you total and then semicolon and forget the dollar sign.
And before the dollar sign, I'm just going to say.
Don't tell.
Payment.
And then semicolon and then dollar sign.
And of course, you can display whatever you want to display.
But I would recommend just keeping everything simple and just display this go to total amount.
And then we need to display also an input.
And that input is going to have a first class.
I'm going to take less end and I'm going to say value and the value is.
Complete payment or proceed.
Pay now or pay now?
Let's say pay now.
And I'm going to also say, do I submit?
Time.
Types a met.
And that's it.
I'm going to be working on this later.
And before this thing, there is a couple of things I need to fix.
The first thing is that in the place ordered at BHP, you'll find that the payment that BHP is not in
the same directory as the please underscore order that BHP therefore would need to say that that.
And then for slash because we need to go back or go out of the of the server because the lease or that
BHP is inside the server folder.
And if we just say payment without done that, it is going to try to find the payment that BHP in the
silver folder and it's not going to find it and we are going to get an error.
So we need to say that, that in order to go back and then we will be able to access the payment or
we can move the payment.
You can move the payment to the server.
Let's move.
Let's move the payment to the server.
If you want to keep things, just keep it like this.
I don't want to confuse you right now.
So here, don't forget that and therefore slash payment that BHP, another thing that they want to do
is that in the payment that BHP at the top at the top here.
You need to hear.
We don't need to hear this.
Good.
We just want to display the payment page so we don't need this.
Let me remove this code for now.
The only code that we want is.
Is the session.
So we just need to say, session, start here.
We just need to say session start.
So you need to say session start.
And then you can hear say echo and then total payment.
And by the way, you can display the message.
Let me show you the message that you can display.
You can simply the message got passed from the place order.
So the place order.
I said, your order status is equal to ordered, placed successfully, successfully.
You can place this message by by accessing the get parameter so you can use, say, B2B and then.
And then you can say echo, echo.
And then you can echo the get get a dollar sign and then get.
Dollar sign here and then get.
And then order, status order or their score status and that's it.
You can display it here.
And don't forget the dollar sign limit.
Click on file Invincible.
And let me now head on over to the browser artist.
So let's add something to the cart and start the process from from the beginning.
So I'm going to click on buy now and we should have this product in the cart.
I already have this product in the cart, by the way.
So let me check out and place an order.
Let me fill out this form quickly.
So I filled out this form limit.
Click on place order and see what's going to happen.
So if you click on this order, as you can see, you are going to get your order placed successfully
and then total payment is this amount and then pay now button.
So we just need to fix here the visa and I'm going to say text center, tech center because they want
to center these things.
And I also want to say here BTN primary within PRI my for now just for now and I can change it later.
Let me refresh.
And as you can see, I'm going to get this message order placed successfully and I want to remove the
quotes from the order status.
So here in the last order, we need to remove this double cross.
I'm going to remove this and I'm going to remove this.
And I should.
Leave me remove this as well.
I'm going to remove this and I'm going to remove this as well.
And let me refresh and as you can see, we have here order placed successfully total payment is this
and then pay now about it so payment I'm going to be working.
What I wanted to tell you is that I'm going to be working on payment later because it's going to take
a lot of time.
So I'm going to be working on payment later.
But for now, we just need to know that the last step is that is payment.
So we, we added the product to cart.
We place the order in the database.
Everything's fine except for being so payment.
We just need to work on it later and for now we need to work on other things and complete other things
until we are done.
And then I'm going to be working on payment.