wordpress - How to display block or trigger the style on Woocommerce if !is_in_stock -


i trying display block or div when product out of stock condition not appear work

add_action( 'woocommerce_get_availability', 'display_welcome', 10); function display_welcome() { global $_product;  if ( ! $_product->is_in_stock() ) {     ?>          <style>             #hello {display:block }          </style> <?          }       } 

html

 <div id="hello">try product instead</div> 

add_action('woocommerce_get_availability', 'display_welcome', 10, 2);  function display_welcome($availability_class, $_product) {      if ($availability_class['availability'] == 'out of stock') {         $availability_class['class'] = $availability_class['class'] . ' my-customclass';         add_action('woocommerce_single_product_summary', 'hooks_add_div', 33);          function hooks_add_div() {             echo '<div id="helllo">mujeebu rahman</div>';         }      } } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -