Hide A Class and Add Custom HTML Code Using WordPress

You mixed JavaScript code with css.

Going by the code you provided you would need to do this.

<?php if (!is_user_logged_in()) : ?>
<style>
    .product-purchase-box{
        display: none;
    }
</style>
<script>
    ($ => {
        $(".single-product-widget").text("Please Login/Register To Download");
    })(jQuery);
</script>
<?php endif; ?>