mercredi 24 mars 2021

show receipt button only when all item in order_list is set as complete

I want to make my receipt button only be shown to click when the order_status been updated to ($irow['order_status'] == 5). It would be much appreciated if you all can provide me a code demo to show me how should I implement this using php. Thanks!

I tried the below codes but it wasn't working. the receipt button will still show up when not all the order_status are equal to 5. How do I enable the receipt only when all of the order statuses are equals to 5?

<div class="col-12 form-group orderidfocus">
      <div class="product-wrapper" id="<?php echo $row['order_id']; ?>">
        <p class="pl-2 pt-2 pr-2">OrderID: <?php echo $row['order_id']; ?>
        </br><?php echo $item_deliver_method ?> Date: <?php echo $row['delivery_date']; ?></p> 
        <hr style="border: 0.5px dashed #DBDBDB;">
        <?php 
        $isql = "SELECT * FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE ordered_items.order_id = '".$row['order_id']."' ";
        $iquery = $conn->query($isql);
        while ($irow = $iquery->fetch_assoc()) {
          if($irow['order_status'] == 1) {
            $order_status = '<div class="badge-secondary font-italic p-1">Waiting for Response </div>';
          }
          if($irow['order_status'] == 2) {
            $order_status = '<div class="badge-warning font-italic p-1">Preparing</div>';
          }
          if($irow['order_status'] == 3) {
            $order_status = '<div class="badge-info font-italic p-1">In Delivery</div>';
          }
          if($irow['order_status'] == 4) {
            $order_status = '<div class="badge-danger font-italic p-1">Ready to Pick up</div>';
          }
          if($irow['order_status'] == 5) {
            $order_status = '<div class="badge-success font-italic p-1">Completed</div>';
          }
          if($irow['order_status'] == 5){
            print ' <a id="receiptbtn" target="_blank" 
                href="receipt.php?order_id=' . $row['order_id'] . '" 
                class="btn addtocart" style="font-size: 12px;"><span class="iconify" data-icon="bx:bx-download" data-inline="false"></span> Receipt</a>';
        }
        else{
            print '<a href="#" class="disabled-link">Receipt</a>';
        }
         
        ?>
        
        <div class="row h-100 pl-2 pr-2 form-group">
          <div class="col-12">
             <small class="float-right"><?php echo $order_status; ?></small>
          </div>
          <div class="col-3 my-auto form-group">
            <img class="order-page-img-thumbnail" loading="lazy" src="images/product-main/<?php echo $irow['product_photo']; ?>" alt="">
          </div>
          <div class="col-5 pl-0 pr-0 my-auto form-group">
            <div class="product-title"><?php echo $irow['product_title']; ?></div>
            <small><?php echo $row['order_type']; ?></small>
          </div>
          <div class="col-4 pl-0 my-auto form-group">
            <div class="product-price" style="text-align: right;">
              RM<?php echo $irow['product_price']; ?>/<?php echo $irow['product_unit']; ?><br>
              <span style="color: #00644C;">X<?php echo $irow['quantity']; ?></span>
            </div>
          </div>
        </div>
        
      <?php } ?>

This is the result i got from the codes above. This is the result i got

Aucun commentaire:

Enregistrer un commentaire