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

Feature: Update all form goal blocks/shortcodes to respect the new v3 fields/queries #7380

Merged

Conversation

alaca
Copy link
Member

@alaca alaca commented May 2, 2024

Description

This PR updates all form goal blocks/shortcodes to respect the new v3 fields/queries.
[give_goal] shortcode is updated and now it supports two new arguments start_date and end_date where the user can set a date range for the goal.

Affects

  • Multi-Form Goal block
  • [give_goal]
  • [give_multi_form_goal]
  • [give_totals]

Testing Instructions

Pre-review Checklist

  • Relevant @unreleased tags included in DocBlocks
  • Self Review of code and UX completed

@alaca alaca requested a review from kjohnson May 2, 2024 12:58

return Money::ofMinor($results->total, give_get_option('currency'))->getAmount();
foreach($this->getForms() as $formId) {
Copy link
Member

Choose a reason for hiding this comment

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

@alaca what do you think about updating the query to accept multiple form IDs? We could update the where to be a whereIn.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great idea. I added a new method forms where you can pass an array of form IDs. See 35eb534

*/
$form_income = 0;

if ($args['start_date'] === $args['end_date']) {
Copy link
Member

Choose a reason for hiding this comment

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

I might suggest instantiating the query and setting the ->form() value and then conditionally setting a between() value, as opposed to duplicating the new DonationQuery code.

On that note, I've considered adding a ->tap($callback) method to the DonationQuery class which would be great for this.

For example:

(new DonationQuery)
    ->form(1)
    ->tap(function($query) {
       if($startDate && $endDate) {
           $query->between($startDate, $endDate);
        }
    })
    ->sumIndendedAmount()
;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored it a bit 7ea042e

If you could add the tap method, that would be great.

@kjohnson kjohnson self-requested a review May 6, 2024 15:49
@alaca alaca merged commit 0314393 into epic/time-based-form-goals-GIVE-565 May 6, 2024
20 checks passed
@alaca alaca deleted the feature/update-shortcodes-GIVE-678 branch May 6, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants