skip to Main Content

I’m building a e-shop with woocommerce. Now i’m modifying the order_detail.php.
I have changed the code this way. Now i have e blank page.
Can somone please help me and explain what’s wrong?

<?php if ( $show_purchase_note && $purchase_note ) 
        {               
             <th>
                 <td><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
             </th>
         }else
         {          
         <td id="placeholder-table">
             <div class="col grid-col large-8 grid-col-1-1">
                 <div class="banner-inner fill">
                     <div class="banner-bg fill">
                         <div class="bg fill bg-fill bg-loaded">
                         </div>
                     </div>
                 </div>
             </div>
         </td>  
         } 
         ?>

2

Answers


  1. It looks like you aren’t opening/closing your php code properly. Take a look at this revised code:

    <?php if ( $show_purchase_note && $purchase_note ){ ?>
        <th>
            <td><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
        </th>
    <?php }else{ ?>     
        <td id="placeholder-table">
            <div class="col grid-col large-8 grid-col-1-1">
                <div class="banner-inner fill">
                    <div class="banner-bg fill">
                        <div class="bg fill bg-fill bg-loaded"></div>
                    </div>
                </div>
            </div>
        </td>  
    <?php } ?>
    

    Anytime you’re switching between PHP and HTML, you need to be sure to wrap your php code in an opening ‘<?php‘ and a closing ‘?>‘. You’ll see an example of this on the line that says <?php }else{ ?>

    You can learn more about this here.

    Login or Signup to reply.
  2. Your code throws a parse error with Parse error: syntax error, unexpected ‘<‘

    please use be care when using html codes inside php tag

    please find the updated code below

    <?php if ( $show_purchase_note && $purchase_note ) 
            {               
                 <th>
                     <td><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
                 </th>
             }else
             { ?>         
             <td id="placeholder-table">
                 <div class="col grid-col large-8 grid-col-1-1">
                     <div class="banner-inner fill">
                         <div class="banner-bg fill">
                             <div class="bg fill bg-fill bg-loaded">
                             </div>
                         </div>
                     </div>
                 </div>
             </td>  
             <?php 
    } 
             ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search