Answers.Body: <p>The Contribution form has this code in the <code>setDefaultValues</code> function:</p>
  <pre><code>$priceFieldName = 'price_' . $values['price_field_id'];
  $priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName);
  </code></pre>
  <p>Direct link: <a href="https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Contribute/Form/Contribution/Main.php#L246" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Contribute/Form/Contribution/Main.php#L246</a></p>
  <p>It should be possible to implement it for events too. Check out the <code>setDefaultValues</code> function in <code>CRM/Event/Form/Registration/Register.php</code>, inside the loop here:</p>
  <p><a href="https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Event/Form/Registration/Register.php#L301" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/aa513711eae7c32ad1cab2e9fd077fffefcf7217/CRM/Event/Form/Registration/Register.php#L301</a></p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-23T15:18:42.803Z
Answers.Text: PR: https://github.com/civicrm/civicrm-core/pull/22313
Answers.UserDisplayName: bgm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-12T15:02:59.367Z
Answers.LastActivityDate: 2021-08-12T15:02:59.367Z
Answers.UserDisplayName: bgm
Body: <p>On contribution pages, I've been able to do this for price sets e.g.</p>
  <p><a href="https://example.org/donate/?price_100=1035" rel="nofollow noreferrer">https://example.org/donate/?price_100=1035</a></p>
  <p>However, I've not been able to get this to work on event pages? What's different and is this possible?</p>
  
Tags: <civievent>
Title: Query string to pre-select price field for events
ThreadText: # Query string to pre-select price field for events
  
  (Asked by: username_0 on 2021-08-12)
  
  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?
  
  **Tags:** civievent
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-12. Score: 2 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_1**: PR: https://github.com/civicrm/civicrm-core/pull/22313  
  
  ---
  
  