What is the proper way to display none for the els

2019-08-13 23:20发布

问题:

Got some help to show this particular hook on the product page on woo commerce. this displays a particular amount when the price is > 20000

and i need to display none when the price is < 20000

Just wanted to know is this the proper way to use else statement.

add_action( 'woocommerce_single_product_summary', 'show_inst_price', 30 );
  function show_inst_price() {
   global $product; 
   $id = $product->get_id();
    $product = wc_get_product( $id );
    $a=$product->get_price();
    if( $a > 20000 ){
    $b  = 5.15464;
    $c = 100;
    $d = $a * $b;
    $total = $d/$c;
      echo '<div class="inst-price" style="font-weight:bold; margin-top: -15px; margin-bottom: 15px;">0% Instalments starting from <span style="color:red;">Rs. ' . number_format($total) . '/month</span></div>';
  }else{
      echo '<span></span>';
             }       
  }

Still the code works perfectly.