So if you get nothing here in order to fix this problem, you can simply change the loop here in the
calculate total order price from while two for each.
So if I say here for each order details as the as or as wrong as row.
Similarly with the loop below here.
And instead of saying, while you need this, we need to save for each and then order details as or
details as raw.
Now if I save and go back to test.
Let me refresh and click on details.
As you can see, it's going to display the orders and we have no problem.
Now, if you click on pay, now, we will have here a very big problem, which is the collision between
the session and the order detail.
So here it says total payment is is nothing.
And then it says that you don't have order.
And then here it says not not me.
So we have a problem.
To fix this problem, we need to establish a strong logic here.
So here, in order to do to do this, we need to re revisit our code here.
And to do this I'm going to open a BGP script and then I'm going to say, firstly, if, if.
Is sex.
And then session if the session total if we have something in the session and and that session total
session total is not total is not equal to zero or is not empty.
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
that we need to display this total amount.
I'm going to copy this line of every.
Move it.
I'm going.
I'm going to sit here.
And then we to remove all this because we already displayed here.
Let me remove all of this.
And here we just need to say.
A year when you say BHP.
BHP.
And then echo.
Decision.
Decision and then we just need to clause here, let me type this from the beginning.
And then here semicolon.
And then we need to close the HP.
And then here we need to say it should be like this.
So this is in case in case the session is not empty.
And in case we have a session, we have something in session.
But.
But we need to remove this code completely now and we need to display the button.
We need also to display the button here.
He went to display the button like this.
So in case the session is total, is not empty, and there is something and the total is not zero,
then we need to display the pay button else if we need to save BHP, maybe add this in a new line BHP
and then if.
If is set a set boast.
Lost.
Order.
Status, order.
Underscore status and and order status based order status.
Is not equal.
Is if it's sit and it's equal to not paid.
Not paid.
Then we need to say here, we need to open bracket.
And here, by the way, we need to close the Kaylie bracket, maybe say Peachtree and then maybe close
the bracket.
And this is the first statement.
Here.
And then he by the way, we need to say ill.
So I'm going to say who else if because this this is a continuation of the previous cuts.
We need to say actually we need to close the Kennelly bracket here and we need to remove this completely.
We can remove this now.
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,
then we need to close that up and then we you to get this.
Good.
Let me get this good.
And then let me pace with here and let me push it.
So here we need to display we need to say if we need we don't need this now.
We just need to display the button and we need to display the be here when it is AP.
And then total payment.
And then he should be.
And then.
Echo.
Bost.
Order.
Go tell Price.
And then semi-colon.
And don't forget to close the attack.
And finally, I'm going to close the year.
I'm going to say I'm going to say you're BHP.
And then else else.
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
doesn't have that order, then we need to take the user to another page or we can display an error message.
We can use HP and then close the candy brackets.
And you also close the candy bracket.
It was the HP actually.
And in between you need to display either an error message or or take the user to another page.
So let me copy this message and then I'm going to say here, you don't have an order.
That's it.
Just you don't have an order.
So let me walk you through the code one more time.
So now we don't need any of this.
We need to remove all of this.
Let me now walk you through this.
So this logic now is very, very clear and well established here in case in case we have something in
the cart.
The first thing you check is the cart.
If something is a cart and if they can't do it, if the total is set, which means that there is something
in the cart, and if that total is not zero, then there is something in the cart.
And we need to display the P button and we need to display the total amount that the user wants to pay
and should pay in order to get the product.
And else if if the total if the session is empty, if the user didn't add anything in the cart, then
he went to check if the user came to this page by clicking on.
By clicking on this button by clicking on.
Mike by checking one of the orders, the old orders, and clicking on one of these bay buttons.
So if that's true, then we need to display the payment and we also need to display the total amount
that they should pay else.
If neither of these is correct, then we need to display.
You don't have an order.
Pretty simple.
Now let me say.
Well, let's test now.
Now, let me go back at this from the beginning.
So let me refresh and click on details.
And now if you click on pay now.
Here.
It's going to display the total amount and it's going to split the paper by now and let's test the other
one.
So the total is correct, by the way, 155 plus 250, the total is 405.
So that's correct.
Let's test another order just to make sure that everything everything is fine.
So limit this this order.
So this order is 150.
If I click on pay now, it's going to here display 150 and here it says Pay now.
Now, let me add something to the card.
Silly me, go to the card and the card now is empty.
So if I go to the homepage and add something to the card, for example, Amy, add this product, I'm
going to add this product by now.
And now the card has only one product.
If I click on, check out and let me fill out this form.
So if I fill out this form and click on place order, as you can see, it's going to display the 149
and pay now, but only once, because now this card works perfectly.
It's going to check for the card if the card is empty, if the card is not empty, like this case,
like in this case, it's going to display the button and the total il6.
If it's empty, then it's going to check the order status.
If the user came to this page via the via their account else is just going to display.
Don't have an order.
Let me prove it to you.
Now, if I go to the card and remove everything from the card, let me remove everything from the card
and let me go to the payment page.
Now, if I go to the payment limit here, say payment got between here, it should display an error
message.
As you can see, it's going to say you don't have an error.
It's not an error message.
It's just a message.
You don't have an error.
So you're going to have you're going to have an order.
So it works successfully.
And now our payment page is perfect and we can proceed to the next step, which is handling payments.