• Resolved revive

    (@revive)


    I’d like to inject an SVG into the .give-recurring-donors-choice element (a heart next to the recurring option).
    I can inject JS that fires when the form loads, but since we’re using a multiple step form, it doesn’t fire for the second step in the form!

    I initially tried to append the img to the element with JS,.. but it wasn’t working.
    Upon further inspection I see the JS is loading when the page loads, but does NOT append the image to the element which is on step two of the form.

    I thought maybe the steps were causing the issue and so I added an on click listener to the Donate Now button, that triggers the second stage of the form to load… it still doesn’t fire for the target element.

    Here is the code:

    function override_givewp_js() { ?>
    	<script type="text/javascript">
    		alert('script is included in page'); // this fires 
    			jQuery(document).ready( function($) {
    				$('.give-btn.advance-btn').on('click', function(){
    					alert('button clicked'); // this doesn't fire on click of the Donate Now button, which takes you to the next step - I previously omitted this, but the following lines won't fire with or without it
    						if( $('.give-recurring-donors-choice').length ){
    							alert('should be loading'); // not loading... tried adding the on click function above to look for this element AFTER the Donate Now button was clicked and form loads second step of the form.. no dice.
    						  $('.give-recurring-donors-choice').append('<img src="/wp-content/themes/vertex-ranch-2022/assets/img/icons/solid/love.svg" class="svg-inject icon-svg icon-svg-xs solid-mono text-primary" alt="?" />');
    						}
    				});
    			}); // docready
    	</script>
    <?php
    }
    
    add_action('wp_print_scripts', 'override_givewp_js', 10);
    

    Thoughts or other ways to add an icon to the form element without hacking plugin files??

    ** Does GiveWP allow template override files (like woocommerce) where I can duplicate a form template into a theme folder and override it ???

    • This topic was modified 2 years, 3 months ago by revive.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Rick Alday

    (@mrdaro)

    Hi @revive,

    Happy to clarify.

    Currently, the templates cannot be overwritten like you can with WooCommerce.
    You can do a lot of customization using CSS instead.

    You can add the image to the recurring donation option using CSS as shown on this screenshot.
    https://screencast-o-matic.com/i/c3j0cDVT3n7

    The Multi-Step, and Classic form templates load in an iframe, to make them more resistant to changes made in the theme’s CSS. That’s helpful for avoiding theme conflicts, but makes customizing the style of them a bit more difficult. There are two PHP code snippets in our Snippet library that will help with that process.

    The first is for small changes, and adds some style inline to the donor dashboard or the multi-step donation form: https://github.com/impress-org/givewp-snippet-library/blob/master/form-customizations/css-customizations/style-givewp-iframes.php

    On that one, you modify lines 16-26 with your own CSS.

    The other is for enqueueing your own CSS completely via a custom stylesheet: https://github.com/impress-org/givewp-snippet-library/blob/master/form-customizations/css-customizations/enqueue-style-for-givewp-iframes.php

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

    Please note that this code snippet is provided as an example of how you can extend GiveWP with code. It’s up to you to implement and customize to your liking. We cannot provide support for custom code on your website, only the code that we create and distribute.

    This is the CSS code I used to place the image on the form in the screenshot:

    [id*=give-form] .give-recurring-donors-choice::before {
    		content: url(https://polylang.local/wp-content/uploads/2022/08/heart-svgrepo-com.svg);
    		display: block;
    		width: 20px;
    		height: 20px;
    		position: absolute;
    		top: 17px;
    		left: 10px;
    		}
    		
    		[id*=give-form] .give-recurring-donors-choice label:before { left: 40px !important;}
    		
    		[id*=give-form] .give-recurring-donors-choice > label { margin-left: 50px !important; }

    You can also try the JS route. If you want to add javascript to the multi-step form template use this function:

    function givewp_multistep_js() {
    
    	wp_add_inline_script( 'give-sequoia-template-js', 'your script here' );
    
    }
    add_action( 'wp_enqueue_scripts', 'givewp_multistep_js' );

    Hope that gives you some rails to run on.

Viewing 1 replies (of 1 total)
  • The topic ‘Customize Recurring Add-on Template’ is closed to new replies.