Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter amiroo

    (@amiroo)

    Just now I remove the php file and seems work properly!
    Did you do some edit in your last update to match it with Avada theme?
    Because previously it didnt follow my theme styles but now is following!
    Hope it interact fine as well with PayPal.

    Thread Starter amiroo

    (@amiroo)

    Hi There,
    Thanks for your compliment!
    Yes, I did some edit in an external php file to change “Give Plugin” appearance works with my theme.
    the content of php file is here:

    <?php
    
    /* Editing Give Plugin */
    
    /* Remove Old Action (containing old function) */
    remove_action('give_checkout_form_top', 'give_output_donation_levels');
    
    /* Define new Action */
    function give_output_donation_levels_edited( $form_id = 0, $args = array() ) {
    
        global $give_options;
    
        $variable_pricing    = give_has_variable_prices( $form_id );
        $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true );
        $currency_position   = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before';
        $symbol              = isset( $give_options['currency'] ) ? give_currency_symbol( $give_options['currency'] ) : '$';
        $currency_output     = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>';
        $default_amount      = give_format_amount( give_get_default_form_amount( $form_id ) );
        $custom_amount_text  = get_post_meta( $form_id, '_give_custom_amount_text', true );
    
        do_action( 'give_before_donation_levels', $form_id );
    
        //Set Price, No Custom Amount Allowed means hidden price field
        if ( $allow_custom_amount == 'no' ) {
            ?>
    
            <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" value="<?php echo $default_amount; ?>" required>
            <p class="set-price give-donation-amount form-row-wide">
                <?php
                if ( $currency_position == 'before' ) {
                    echo $currency_output;
                }
                ?>
                <span id="give-amount" class="give-text-input"><?php echo $default_amount; ?></span>
            </p>
            <?php
        } else {
            //Custom Amount Allowed
            ?>
            <div class="give-total-wrap">
                <div class="give-donation-amount form-row-wide">
                    <?php
    
                    if ( $currency_position == 'before' ) {
                        echo $currency_output;
                    }
                    ?>
    
                    <input class="give-text-input" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" required autocomplete="off">
    
                    <?php if ( $currency_position == 'after' ) {
                        echo $currency_output;
                    } ?>
    
                    <p class="give-loading-text give-updating-price-loader" style="display: none;">
                        <span class="give-loading-animation"></span> <?php _e( 'Updating Amount', 'give' ); ?>
                        <span class="elipsis">.</span><span class="elipsis">.</span><span class="elipsis">.</span></p>
                </div>
            </div>
        <?php }
    
        //Custom Amount Text
        if ( ! empty( $custom_amount_text ) && ! $variable_pricing && $allow_custom_amount == 'yes' ) { ?>
            <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p>
        <?php }
    
        //Output Variable Pricing Levels
        if ( $variable_pricing ) {
            give_output_levels_edited( $form_id );
        }
        do_action( 'give_after_donation_levels', $form_id, $args );
    }
    
    /* Add New Action to Removed Action */
    add_action( 'give_checkout_form_top', 'give_output_donation_levels_edited', 10, 2 );
    
    /* Create New Function as Output */
    function give_output_levels_edited( $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 .= '<p><label></label><span class="wpcf7-form-control-wrap"><div class="wpcf7-select-parent">';
    
                $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level">';
    
                //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>';
    
                $output .= '</div></span></p>';
    
                break;
        }
    
        echo apply_filters( 'give_form_level_output', $output, $form_id );
    }

    Could you please guide me what’s wrong as it was working properly before update?

    Thanks

    Thread Starter amiroo

    (@amiroo)

    Sure, Here you are.
    Thanks

    Thread Starter amiroo

    (@amiroo)

    I’ve checked everything, its not duplicated from admin side.
    Also when I check codes from browser dev-tools, I see form is not duplicated but div with class=”give-total-wrap” and a button have been duplicated.
    Can you help me to solve it?
    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 5 replies - 1 through 5 (of 5 total)