How to access page variable inside action hook

There is method on product class that is called is_on_sale() which actually determines if the product is on sale or not. You can access it from global $product variable. And must echo the do_shortcode. So the whole code will be like-

add_action('woocommerce_single_product_summary','add_product_signup', 10, 2);
function add_product_signup() {
    global $product;
    if( $product->is_on_sale() ) {
        echo do_shortcode('[contact-form-7 id="20709" title="Product Sale Notification Signup"]');
    }
}

The above code is tested. I tested it personally and it worked pretty well.

tech