Mount "if"s according to criteria

Asked

Viewed 110 times

-1

I’m having a question on the condition I’m willing to put in my system. In case the site will check if the "Paid" is with the result 1; if you have 1, it will put "Delivered", but if you have 0 it is "Pending", now if the value is refunded it was to be "Redeemed" and take out the "Delivered" or "Pending", how can I do it?

Follows the code:

<?php if($transaction->paid == 1): ?>
    <td><span class="badge badge-success">Entregue</span></td>
<?php else: ?>
    <td><span class="badge badge-warning">Pendente</span>/td>
<?php endif; ?>

<?php if($transaction->status == refunded): ?>
    <td><span class="badge badge-danger">Rembolsado</span></td>
<?php endif; ?>

2 answers

3


First place the condition of status and a else where there will be another if for the condition of paid:

<?php if($transaction->status == refunded): ?>
<td><span class="badge badge-danger">Rembolsado</span></td>
<?php else: ?>
   <?php if($transaction->paid == 1): ?>
<td><span class="badge badge-success">Entregue</span></td>
   <?php else: ?>
<td><span class="badge badge-warning">Pendente</span></td>
   <?php endif; ?>
<?php endif; ?>

3

Probably has a conceptual error in the system, but since it is so can solve this way (I hope I understood and have been correctly put the criteria):

<?php if($transaction->status == "refunded"): ?> //isto provavelmente está errado, mas foi colocado errado, não sei qual deva ser o certo
    <td><span class="badge badge-danger">Rembolsado</span></td>
<?php else: ?>
    <?php if ($transaction->paid == 1): ?>
        <td><span class="badge badge-success">Entregue</span></td>
    <?php else: ?>
        <td><span class="badge badge-warning">Pendente</span></td>
    <?php endif; ?>
<?php endif; ?>

I put in the Github for future reference.

Thus if the status is refunded he assumes that this is what matters, otherwise he will verify the paid. I considered that the refund has priority according to the description. This is called if nestled.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.