function to add note on single Woo Commerce product page for downloadable variations

For variable product, it’s not the product that you need to test but the variations :

add_action( 'woocommerce_before_add_to_cart_button' , function () {

    global $product;


    $downloadable = FALSE;


    if ("simple" === $product->get_type()) {

        $downloadable = $product->is_downloadable();

    } elseif ("variable" === $product->get_type()) {

        $variations = $product->get_available_variations();

        foreach ($variations as $variation) {

            if ($variation["is_downloadable"]) {
                $downloadable = TRUE;
                break;
            }

        }

    }



    if ($downloadable) {
          echo '<p>Please note: a link to your downloadable product will be 
          available on the purchase confirmation page.</p>';
    }


});

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