• Resolved huzaifahj

    (@huzaifahj)


    Hey! Thanks for all your previous help here.

    I’m using some custom jquery to set the donation amount externally (e.g. using GET and a custom link).

    This is my code, I have looked at a similar post in the past but the javascript didn’t seem to work. What could be wrong? Everything shows up fine but I get “Donation amount £10.00 is invalid”.

    <script>
      jQuery( document ).ready(function() {
      jQuery('#give-amount').val(10);
      jQuery('#give-amount').attr('data-amount',10);
      jQuery('.give-final-total-amount').attr('data-total',10);
      jQuery('.give-final-total-amount').html('£10.00');
    });
    </script>

    All the best!

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

    (@webdevmattcrom)

    Take out the currency symbol and you should be good to go. The donation amount should only be numberic, the currency is separate.

    Thanks!

    Thread Starter huzaifahj

    (@huzaifahj)

    I’ve tried many combinations of .00s and £s. Your suggestion isn’t working for me unfortunately.

    What else could it be?

    Thread Starter huzaifahj

    (@huzaifahj)

    Nevermind then,

    For GiveWP developers, the error I got was due to the ‘Custom’ not being clicked. I have simulated this in jQuery and it works now. You may want to consider an easier way to allow dynamic amounts in future.

    For anyone looking at this thread, this is how I solved it:

    jQuery("button[data-price-id=custom]").trigger("click");
      
    jQuery('#give-amount').attr('value', amount)
    jQuery('#give-amount').attr('data-amount',amount);
    jQuery('.give-final-total-amount').attr('data-total',amount);
    jQuery('.give-final-total-amount').html(amount);
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘jQuery and dynamic donation amount’ is closed to new replies.