0

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>  
         } 
         ?>
m41130
  • 3
  • 2
  • im afraid you are not using the php syntax correctly. Probably you have a php error and server just returns blank page – Alberto S. Mar 04 '20 at 18:38
  • See [Escaping from HTML](https://www.php.net/manual/en/language.basic-syntax.phpmode.php). – showdev Mar 04 '20 at 18:53
  • This is a fractal of issues - even when you've solved your immediate issue of the PHP syntax error (you should have noticed this in your logs LONG before started typing stuff into Stackoverflow) the way you are mixing PHP and HTML makes maintaining your code difficult. – symcbean Mar 04 '20 at 21:12

2 Answers2

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.

Joe
  • 1,792
  • 1
  • 16
  • 25
0

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 
} 
         ?>
Subair
  • 91
  • 1
  • 2
  • 8