• Resolved amiroo

    (@amiroo)


    Hi There,
    Thanks for your nice effort in this helpful plugin.
    I wanna override some template to match them with my them but I had a lot of struggles.
    I need to edit templates in this address:
    ../plugins/give/includes/forms
    (Ex: template.php -> function give_output_levels_edited( $form_id )
    Would be appreciate guiding me how to do it through my functions.php them file.
    Thanks

    https://wordpress.org/plugins/give/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Matt Cromwell

    (@webdevmattcrom)

    Hi there, thanks for your kind words. Are you familiar with our documentation? We have some detailed guidance there:
    https://givewp.com/documentation/developers/themeing-with-give/

    Review that and let me know how it goes. Thanks!

    Thread Starter amiroo

    (@amiroo)

    Thanks for your quick reply,
    Actually I’m not very good at WP hooks and filters (but trying to figure them out!), I’ve read the well explained documentations and have tried to use filters and hook to following function, but didn’t work (probably the lack of WP filtering and hooking knowledge), so knowing it might be out of your support zone, would be great if you help me how can I edit following function through my functions.php file.

    function give_output_levels( $form_id ) {
    
    	//Get variable pricing
    	$prices             = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
    	$display_style      = get_post_meta( $form_id, '_give_display_style', true );
    	$custom_amount      = get_post_meta( $form_id, '_give_custom_amount', true );
    	$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
    	$output             = '';
    	$counter            = 0;
    
    	switch ( $display_style ) {
    		case 'buttons':
    
    			$output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">';
    
    			foreach ( $prices as $price ) {
    				$counter ++;
    
    				$output .= '<li>';
    				$output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class="give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ) . '" value="' . give_format_amount( $price['_give_amount'] ) . '">';
    				$output .= ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ) );
    				$output .= '</button>';
    				$output .= '</li>';
    
    			}
    
    			//Custom Amount
    			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
    				$output .= '<li>';
    				$output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">';
    				$output .= $custom_amount_text;
    				$output .= '</button>';
    				$output .= '</li>';
    			}
    
    			$output .= '</ul>';
    
    			break;
    
    		case 'radios':
    
    			$output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">';
    
    			foreach ( $prices as $price ) {
    				$counter ++;
    
    				$output .= '<li>';
    
    				$output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ) . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">';
    
    				$output .= '<label for="give-radio-level-' . $counter . '">' . ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ) ) . '</label>';
    
    				$output .= '</li>';
    
    			}
    
    			//Custom Amount
    			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
    				$output .= '<li>';
    				$output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">';
    				$output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>';
    				$output .= '</li>';
    			}
    
    			$output .= '</ul>';
    
    			break;
    
    		case 'dropdown':
    
    			$output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level TEST">';
    
    			//first loop through prices
    			foreach ( $prices as $price ) {
    
    				$output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="give-donation-level-' . $form_id . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">';
    				$output .= ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ) );
    				$output .= '</option>';
    
    			}
    
    			//Custom Amount
    			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
    				$output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>';
    			}
    
    			$output .= '</select>';
    
    			break;
    	}
    
    	echo apply_filters( 'give_form_level_output', $output, $form_id );
    
    }

    Thanks and have a great time

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Override Templates’ is closed to new replies.