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

Make default payment block plan names dynamic #25397

Merged
merged 3 commits into from
Aug 5, 2022

Conversation

dsas
Copy link
Contributor

@dsas dsas commented Aug 5, 2022

Partly fixes #24074 but a similar change will be needed in Calypso

Changes proposed in this Pull Request:

When adding a new plan, the plan name will update depending upon the payment options selected - whether it's a donation and what the payment frequency is.

This aids users in naming their plans appropriately and reduces the likelihood of having umpteen plans called 'Monthly subscription' when they're nothing of the sort.

If the user explicitly chooses a name then that is respected and not overwritten.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  1. Start a JN site or apply the wpcom generated diff from the message below
  2. On a site with a paid plan, go to Gutenberg
  3. Insert a Payment button block
  4. Follow prompts to connect to Stripe
  5. Select the payment button block
  6. Click the plan
  7. In the block inspector (sidebar on the right) fiddle around with the Interval and "Mark this payment plan as a donation" fields and watch the title change
  8. Change the title manually
  9. Fiddle with the fields again, and watch the title not change
  10. Add the plan you created, watch the default plan title change back to be appropriate with the interval / donation fields

Demo

Screen.Capture.on.2022-08-05.at.13-46-55.mp4

When adding a new plan, the plan name will update depending upon the
payment options selected - whether it's a donation  and what the payment
frequency is.

This aids users in naming their plans appropriately and reduces the
likelihood of having umpteen plans called 'Monthly subscription'
when they're nothing of the sort.

If the user explicitly chooses a name then that is respected and not
overwritten.
@dsas dsas requested a review from a team August 5, 2022 12:46
@dsas dsas self-assigned this Aug 5, 2022
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello dsas! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D85442-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Aug 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: September 6, 2022.
  • Scheduled code freeze: August 30, 2022.

@@ -83,6 +84,15 @@ export default function ProductManagementInspectorControl() {
);
};

useEffect( () => {
// If the user has manually selected a title then that should be left as-is, don't overwrite it
if ( isCustomTitle ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I could get rid of this state by checking if the current title from the state matches anything that getTitleByProps could return?

Copy link
Member

Choose a reason for hiding this comment

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

Yup, that could work, but it's fine to leave this as-is. The other benefit of getting rid of this state is that if the user undoes their changes and goes back to a default title, we'd be again changing the title according to the type/interval. In other words:

  1. User changes title to "My Subscription"
  2. User changes interval to "Yearly"
  3. User changes title to "Yearly Subscription"
  4. User changes type to "Donation"

The isCustomTitle check would keep the title as "Yearly Subscription", but if replace it with a check against the default values, the title will change to "Yearly Donation".

Anyway, this is an edge case, so feel free to ignore this!

Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

This tests well! I left a minor non-blocking comment, but this good to go.

@@ -83,6 +84,15 @@ export default function ProductManagementInspectorControl() {
);
};

useEffect( () => {
// If the user has manually selected a title then that should be left as-is, don't overwrite it
if ( isCustomTitle ) {
Copy link
Member

Choose a reason for hiding this comment

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

Yup, that could work, but it's fine to leave this as-is. The other benefit of getting rid of this state is that if the user undoes their changes and goes back to a default title, we'd be again changing the title according to the type/interval. In other words:

  1. User changes title to "My Subscription"
  2. User changes interval to "Yearly"
  3. User changes title to "Yearly Subscription"
  4. User changes type to "Donation"

The isCustomTitle check would keep the title as "Yearly Subscription", but if replace it with a check against the default values, the title will change to "Yearly Donation".

Anyway, this is an edge case, so feel free to ignore this!

@mmtr mmtr added this to the jetpack/11.3 milestone Aug 5, 2022
@mmtr mmtr added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Team Review labels Aug 5, 2022
@dsas dsas merged commit 28c2d61 into trunk Aug 5, 2022
@dsas dsas deleted the update/payment-button-product-names branch August 5, 2022 14:27
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

Great news! One last step: head over to your WordPress.com diff, D85442-code, and deploy it.
Once you've done so, come back to this PR and add a comment with your SVN changeset ID (e.g. r12345-wpcom).

Thank you!

@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Aug 5, 2022
@dsas
Copy link
Contributor Author

dsas commented Aug 5, 2022

Deployed r250190-wpcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Payments: Add visual clues for donation products
3 participants