1

On contribution pages, I've been able to do this for price sets e.g.

https://example.org/donate/?price_100=1035

However, I've not been able to get this to work on event pages? What's different and is this possible?

1

The Contribution form has this code in the setDefaultValues function:

$priceFieldName = 'price_' . $values['price_field_id'];
$priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName);

Direct link: https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Contribute/Form/Contribution/Main.php#L246

It should be possible to implement it for events too. Check out the setDefaultValues function in CRM/Event/Form/Registration/Register.php, inside the loop here:

https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Event/Form/Registration/Register.php#L301

I haven't tested it, but if it works for you, I would encourage you to send a pull-request so that it gets reviewed and tested, and eventually included in a future version. It's a useful feature indeed. I can also help with the PR.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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