How to edit plugin files safely?

I want to edit the add to cart section on the product single template of the woocommerce plugin.

I would like to know whether it is a good practice to put the code directly in the file.

If not, what are my alternatives and how do I add the code correctly in order for wordpress to know where I want the code to take effect?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer