• Resolved Josh

    (@jmccallweb)


    Hey, I’m using Multilevel donations with the button display style, and would like to add descriptive text alongside each donation level button. Like this.

    [supporter] Some descriptive text…
    [patron] Some more descriptive text…

    I assume this would mean adding a custom field to the Give admin and then digging into your filters or templates. Hoping you can point me in the right direction?

    Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Matt Cromwell

    (@webdevmattcrom)

    Hi there,

    That can be done with a PHP snippet like this one:
    https://github.com/WordImpress/Give-Snippet-Library/blob/master/form-customizations/add-html-after-multilevel.php

    You would just update the form_id and the level_text per form and per level, then add the relevant HTML in the return statement. If you make progress on that and get stuck, provide your code (preferrably as a Gist or Pastebin) and a link to your form and I can help further.

    If you need guidance implementing custom PHP functions on your website, we have this guide here: https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/

    Thanks!

    Thread Starter Josh

    (@jmccallweb)

    Thanks. I’ll see how far I can get with this next week.

    Thread Starter Josh

    (@jmccallweb)

    Hey Matt,

    This works almost perfectly. Is there a way to change snippet so it adds the custom text after the closing </button> tag. Right now it looks like this:

    ` <li>
    <button type=”button” data-price-id=”2″ class=” give-donation-level-btn give-btn give-btn-level-2 ” value=”40.00″>Small<br><span class=”available”>Available through 4/30</span></button> **
    </li>`

    I’d love to be able to insert the text where the two asterisks are above.

    PS One more question. Is it possible to allow HTML tags within the label text? By default, it looks like all that is removed when I save the form.

    • This reply was modified 6 years, 10 months ago by Josh.
    • This reply was modified 6 years, 10 months ago by Josh.
    Plugin Author Matt Cromwell

    (@webdevmattcrom)

    We don’t have a filter for after the level button. But using that filter, you can add HTML within the text like so:

    function prefix_customize_give_buttons( $level_text, $form_id, $price ) {
    	// Check for form_id and specific level text first
    	if ( $form_id == 25 && $level_text == 'Jedi Grand Master' ) {
    
    	    $level_text = 'Jedi <strong>Grand</strong> Master';
    		// Return your custom HTML
    		return $level_text . '<br /><span class="available"><small>Available through 4/30</small></span>';
    	}
    	// Return all Level Texts
    	return $level_text;
    }
    add_filter( 'give_form_level_text', 'prefix_customize_give_buttons', 10, 3 );

    Thanks!

    Thread Starter Josh

    (@jmccallweb)

    That’s not going to work for us because we need the extra text inserted after the button wrapper.

    We’ll probably revert to the radio buttons instead. For those, is there a way to allow html within the donation level fields?

    Basically, I need to be able to add spans and classes so that I can style the text alongside the radio buttons, but right now you seem to be stripping out all the html when the form is saved. Is it possible to NOT do that? I understand why you’d want to do that usually, but in this case I need the html to not get removed.

    Thanks again. I love this plugin.

    Plugin Author Matt Cromwell

    (@webdevmattcrom)

    I don’t have a snippet for this, but the entire multi-level output itself is run through one filter called give_form_level_output. You can find that whole thing in this file:
    give\includes\forms\template.php

    You could conditionally filter that with your form output as well and essentially hardcode the levels. But you’ll want to make sure the markup is EXACT so that the levels are influenced by our existing javascript without problem.

    Hope that helps, and thanks for your really kind review. We appreciate it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Output text alongside donation level buttons’ is closed to new replies.