Add “add to cart” button in WooCommerce [closed]

You’re right about not doing this inside the theme file, also you have the right thing in mind putting this into your functions.php. Try the approach shown below, it’s more you actually need, so pick what’s fitting in your case.

Code:

    //remove add to cart buttons
    add_action( 'init', 'wpse124288_wc_remove_add_to_cart_buttons' );
    function wpse124288_wc_remove_add_to_cart_buttons() {
        //add to cart button loop
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
        //add to cart button single product
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }

    //(re)add add to cart buttons
    add_action( 'init', 'wpse124288_wc_readd_add_to_cart_buttons' );
    function wpse124288_wc_readd_add_to_cart_buttons() {
        //add to cart button loop
        add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
        //add to cart button single product
        add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }