Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds on #27049 to extract getPriceSetID() #27050

Merged
merged 3 commits into from
Aug 23, 2023

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 11, 2023

Builds on #27049 to extract getPriceSetID()

Before

discountID (newly) pass in to CRM_Event_Form_Registration::initEventFee( - but used only to get priceSetID

After

$priceSetID passed in

Note that the getPriceSetID function now handles setting the form property & form value, as used. So I removed that from the shared code. I didn't put it in the setting for ParticipantFeeSelection because it is currently interacting with an undefined property

Technical Details

Per #27049 the only other usage is a unit test @mlutfy wrote

@civibot
Copy link

civibot bot commented Aug 11, 2023

Thank you for contributing to CiviCRM! ❤️ We will need to test and review the PR. 👷

Introduction for new contributors
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers

@civibot civibot bot added the master label Aug 11, 2023
@eileenmcnaughton eileenmcnaughton force-pushed the price branch 5 times, most recently from 278b758 to 1ff517e Compare August 11, 2023 07:59
@eileenmcnaughton eileenmcnaughton changed the title [wip] bbbbbPrice Builds on #27049 to extract getPriceSetID() Aug 11, 2023
@eileenmcnaughton eileenmcnaughton force-pushed the price branch 3 times, most recently from ae812bc to 158a4b6 Compare August 12, 2023 03:37
@eileenmcnaughton eileenmcnaughton force-pushed the price branch 9 times, most recently from e8fc6fb to 54b8d5c Compare August 18, 2023 03:45
@eileenmcnaughton
Copy link
Contributor Author

test this please

* @noinspection PhpUnhandledExceptionInspection
* @noinspection PhpDocMissingThrowsInspection
*/
public function getPriceSetID(): ?int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use this at 127 as well for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, $priceSetId is unused, we can just remove 127.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@@ -1428,7 +1428,7 @@ public function buildEventFeeForm($form) {

//retrieve custom information
$form->_values = [];
CRM_Event_Form_Registration::initEventFee($form, $event['id'], FALSE, $form->getDiscountID());
CRM_Event_Form_Registration::initEventFee($form, $event['id'], FALSE, $this->getPriceSetID());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes any difference as things stand now, but shouldn't it be $form->getPriceSetID for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - I've been trying to go the other way for consistency - ditch the use of form & even the passing of it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I guess it doesn't matter here as long as this doesn't get called from anywhere else, just looks a bit odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 yeah that needs cleaning up - although as long as this PR passes tests it is out of scope for it

@larssandergreen
Copy link
Contributor

larssandergreen commented Aug 22, 2023

Started giving this an r-run, which is quite tricky as some of this stuff doesn't work very well presently.

But to start, if you:

  1. Add a discount to a quick config price set for an event
  2. Register a participant
  3. View the participant
  4. Change selections

Then you can no longer edit the selections for the participant (that part doesn't show up at all).

Before
image

After
image

@larssandergreen
Copy link
Contributor

Also noting, though I suppose it is technically out of scope here as it is the current behaviour on master: if I change selections for a registration with a discounted price set, I expect the options to show the discounted price set, but what I get is the current price set based on the current date. For example, if someone registered for a student ticket with an early bird discount and I need to change them to an adult ticket, I would expect they would still get the early bird price.

I thought initEventFee was supposed to get the price set that the participant currently had based on the discount id, but that doesn't seem to be happening.

@eileenmcnaughton
Copy link
Contributor Author

@larssandergreen thanks for that - I think I agree with you that the price set they selected from should be the one that is loaded so I will check in on that

@eileenmcnaughton
Copy link
Contributor Author

Oh - the issue is that ParticipantFeeForm no longer has the undefined property set _priceSetId - ideally we would pass it into the function rather than require it from the form - just trying to see where it is called from / when it would NOT be set....

image

@@ -423,7 +423,7 @@ public function buildQuickForm() {
// build amount only when needed, skip incase of event full and waitlisting is enabled
// and few other conditions check preProcess()
if (!$this->_noFees) {
self::buildAmount($this);
self::buildAmount($this, FALSE, NULL, $this->_priceSetId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$required was TRUE by default before, now FALSE - intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opps no

@larssandergreen
Copy link
Contributor

larssandergreen commented Aug 22, 2023

Confirming that missing price set options for Change Selections is fixed.

The discounted price set still isn't loading when editing a participant. I noticed that it looks like the discount id isn't loading when editing the registration at all. I think we should see a discount set here when the registration used a discounted price set.
image

This gets away from it needing to be set on the form as a property
@eileenmcnaughton eileenmcnaughton force-pushed the price branch 5 times, most recently from e4de92b to 613887a Compare August 22, 2023 20:30
@eileenmcnaughton
Copy link
Contributor Author

whoa that discount code is a can of worms - it adds the property to the form only if the property context exists - which is only true for one of the forms involved Participant - but that ONLY uses if within the same function. I've moved that back to the form as a first step - it might be good to fix the ParticipantFeeSelection not offering the discount in a follow up as this should be a refactor only. I guess I need to check if only back-office users can use that form cos only back office users should get the choice.

Hmm that's a question - it makes sense that a back-office user can change the event selection within the same time-based discount set- but should a self-service user? I suspect not - if they want to do that they maybe have to contact the organization as the discount might depend on them paying on time & they could work the system by buying a cheap ticket early & getting the expensive one later

@larssandergreen
Copy link
Contributor

OK, makes sense. Yes, let's do the discount thing separately.

Looks like the test fails are related.

@eileenmcnaughton
Copy link
Contributor Author

@larssandergreen
Copy link
Contributor

Now just a concurrency test fail, so good.

@@ -540,12 +540,13 @@ public function buildQuickForm() {
* Form object.
* @param bool $required
* True if you want to add formRule.
* @param int $discountId
* @param null $discountId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int|null

@larssandergreen
Copy link
Contributor

Another small related bug in master. Not an issue here.

@larssandergreen
Copy link
Contributor

OK, I've given this a fairly thorough run and I think it is ready to merge.

@larssandergreen
Copy link
Contributor

Excepting that one docblock issue above

This is ths only one of the forms that has context as a property so the only one that does it
@eileenmcnaughton
Copy link
Contributor Author

I fixed the docblock & the test magically passed

@colemanw colemanw merged commit 6373878 into civicrm:master Aug 23, 2023
@colemanw colemanw deleted the price branch August 23, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants