Add custom body tag if product is out of stock

add_filter('body_class', 'SE_314220_custom_outofstock_class');

 function SE_314220_custom_outofstock_class ($classes) {

  global $post;
  if($post->post_type !="product")
    return $classes;
  $product = wc_get_product( $post->ID );
  if($product->get_stock_quantity() ==0)
    $classes[] = 'OUT-OF-STOCK';
  return $classes;
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)