Is there a quick way to pass in the contribution amount via URL on custom amounts?


I'm not looking to use a price set, just a total amount. Ideally, I'd like to pay an existing contribution and bring up a form with the amount and contribution to pay against with a credit card.

2 Answers 2


I just tried this on CiviCRM 4.6.18 and successfully passed the amount through using the field Name or id (inspect the field to find the name or id) In the case of my form I did this: http://example.org/civicrm/contribute/transact?reset=1&id=2&price_5=35

  • This is still working on civicrm 5.x.x Commented Aug 29, 2019 at 4:24

If a javascript solution suits you:

var a = document.createElement('a');
a.href = document.location;
var amount = a.search.match(/amount=([0-9]+)/)[1];
jQuery('#search input[name="q"]').val(amount);
  • Visit this URL -- current page + ?amount=1234
  • Paste the above code in your browser console
  • Observe that the StackExchange search box now contains the value from the current page's query params.
  • Add a free-text amount input to your contribute form.
  • Use equivalent approach to populate that value on your own site.
  • 1, 2. The first two lines look weird, but they are just there to allow the third to easily steal the query param from the current URL. Commented Aug 24, 2015 at 4:12
  • Thanks for the solution .It would be great to have a CiviCRM generated form, ideally attached to the Contribution ID. The idea is to apply a payment using the CiviCRM payment processor to an existing contribution. I was hoping I could use an existing contribution form and pipe the contribution ID and amount in.
    – Adam
    Commented Aug 24, 2015 at 8:58
  • The solution above is intended for that use case. If you need it in the page instead of via JS, you want hook_buildform() in a custom extension I think. Commented Aug 24, 2015 at 9:16
  • Thanks. Did you have an example to get started?
    – Adam
    Commented Aug 24, 2015 at 10:16
  • The civi tracker module linked in the wiki article on this comment is an example with similar functionality if you join the dots. Commented Aug 24, 2015 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.