• pbosakov

    (@pbosakov)


    If there is both a drop-down list and a custom amount box, when the user types in a custom amount, the browser will submit both fields, causing PayPal to spit out an error message.

    I have patched WP_Accept_Paypal_Payment.php to fix that. Please consider testing and updating this in the next release.

    162a163
    >             $('select[name=amount]').prop('disabled', true);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author mra13

    (@mra13)

    Can you please share the full code block?

    Thread Starter pbosakov

    (@pbosakov)

    This is the full code block that outputs some Javascript code, with my added line that will disable the “amount” field when “other amount” is selected.

        $output .= <<<EOT
    <script type="text/javascript">
    jQuery(document).ready(function($) {
        $('.wp_accept_pp_button_form_classic').submit(function(e){
            var form_obj = $(this);
            var other_amt = form_obj.find('input[name=other_amount]').val();
            if (!isNaN(other_amt) && other_amt.length > 0){
                options_val = other_amt;
                //insert the amount field in the form with the custom amount
                $('<input>').attr({
                    type: 'hidden',
                    id: 'amount',
                    name: 'amount',
                    value: options_val
                }).appendTo(form_obj);
                $('select[name=amount]').prop('disabled', true);
            }		
            return;
        });
    });
    </script>
    EOT;
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PayPal error when custom amount field is used’ is closed to new replies.