Support » Plugin: WooCommerce » Change add to cart to Download now if the price is Zero

  • Hi,

    I would like to change the add to cart button on the single product page to Download Now if the item is Free and the price is set zero display Download Now. otherwise show the add to cart button if the price is not zero.

    I have tried this on the theme function but no luck…?

    add_action( 'woocommerce_single_product_summary', 'wa_change_add_to_cart', 10 );
    
    function wa_change_add_to_cart() {
        global $product;
        $downloads = $product->get_files();	
    
        foreach( $downloads as $key => $each_download ) {
    echo '<form action="' . esc_url($each_download["file"]) . '" method="get">
                <button type="submit" class="single_add_to_cart_button button alt">Download Now</button>
              </form>';}
    }
  • The topic ‘Change add to cart to Download now if the price is Zero’ is closed to new replies.