• Resolved euro11

    (@euro11)


    Hi,

    I found the code below from here and it beautifully changes button text for free downloads :

    /**
     * Easy Digital Downloads
     * Change the button text of a free download. Default is "Free - Add to Cart"
    */
    function sumobi_edd_free_download_text_args( $args ) {
    	// Enter the button text for a free download
    	$free_download_text = 'Free download';
    	$variable_pricing = edd_has_variable_prices( $args['download_id'] );
    	if ( $args['price'] && $args['price'] !== 'no' && ! $variable_pricing ) {
    		$price = edd_get_download_price( $args['download_id'] );
    		if ( 0 == $price ) {
    			$args['text'] = $free_download_text;
    		}
    	}
    	return $args;
    }
    add_filter( 'edd_purchase_link_args', 'sumobi_edd_free_download_text_args' );

    But it doesn’t work in variable prices mode (if the price is 0).

    Please help

    • This topic was modified 2 years, 2 months ago by euro11.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Phil Johnston

    (@johnstonphilip)

    Hey there,

    We actually do not provide any custom code assistance here. But if you’d like to hire a consultant to help you, you can do that here: https://easydigitaldownloads.com/consultants/

    If not every price in your store is free, you’ll need the text on the button to change on-the-fly, which would require custom javascript that responds to the radio buttons being changed. You’ll need to hire someone for something like that.

    But if every price in your entire store is free, you can use this:

    
    function sumobi_edd_free_download_text_args( $args ) {
    
    	$args['text'] = 'Free download';
    
    	return $args;
    }
    add_filter( 'edd_purchase_link_args', 'sumobi_edd_free_download_text_args' );
    Plugin Contributor Phil Johnston

    (@johnstonphilip)

    You also have one other option which I’d forgotten about, which is the Free Downloads extension for Easy Digital Downloads. It will change the button text for free products, including variable products, exactly as you are requesting. It does not require any custom code snippets to do so, as it has a built-in option allowing you to define what you want the “free” button to say:

    https://easydigitaldownloads.com/downloads/free-downloads/

    euro11

    (@euro11)

    Thanks Phil,

    But the code snippet doesn’t work and the add-on was NOT what I was looking for. (I should ‘ve seen the demo before I purchase it)

    Anyway, to put it simply :
    All I need is change the 0.00$ (in variable prices mode) to FREE or ORDER. (I mean the price itself not the purchase button) as simple as that !

    If there is any way or any add-on please let me know.

    euro11

    (@euro11)

    or maybe simply hide the price and extra dash (-) if it’s 0.00$

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show FREE if price is 0’ is closed to new replies.