-
Notifications
You must be signed in to change notification settings - Fork 798
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
Pay with PayPal block: Save fallback into post content #17256
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Scheduled Jetpack release: October 6, 2020. E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17256 Thank you for the great PR description! When this PR is ready for review, please apply the |
@mmtr I ran through the tests for the email section and it worked as expected! Just want to note that in your description, this step:
Should wrap the I ran it the first time, not noticing the |
Thanks for testing, @krymson24!
You don't need to sandbox anything for testing this one, so using the production store and not connecting your Jetpack site to your sandbox is fine.
I also saw the SP22 error too, but like you I also get it when testing in
Good catch! I actually wanted to include the php as part of the code formatting :) Updated. |
Found it. It's caused by the new Jetpack plans, which have not been added to the list of plans supporting the "Pay with PayPal" functionality. Should be fixed by D50263-code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tested well for me on Jetpack. I have one comment, but it's not a blocker, it could be addressed in a follow-up PR. It should be good to merge!
} | ||
|
||
// Keep content as-is if rendered in other contexts than frontend (i.e. feed, emails, API, etc.). | ||
if ( ! jetpack_is_frontend() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should add a Blocks::is_amp_request()
check here as well, since this may be another context where we'd want to display a simplified block.
cc @westonruter What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this makes sense to me. I assume the button just doesn't work in AMP currently, so serving the fallback static content which we know is AMP-compatible seems correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( ! jetpack_is_frontend() ) { | |
if ( ! jetpack_is_frontend() || Blocks::is_amp_request() ) { |
I'm not set up to test this block, but what does this result in on AMP pages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! 🎉 I went through all the cases, and only had one glitch: I'm not able to complete the purchase on the front-end view. The PayPal modal pops up, but immediately dies with the following (I don't see this at all on prod, so maybe it's something sandbox-related?):
I'm approving, assuming we can determine that the above error isn't a problem related to these changes 👍 |
} | ||
|
||
// Keep content as-is if rendered in other contexts than frontend (i.e. feed, emails, API, etc.). | ||
if ( ! jetpack_is_frontend() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( ! jetpack_is_frontend() ) { | |
if ( ! jetpack_is_frontend() || Blocks::is_amp_request() ) { |
I'm not set up to test this block, but what does this result in on AMP pages?
I'll merge this for now, so I can get started with the release; @mmtr I'll let you handle the WordPress.com counterpart and the feedback above in a follow-up PR? |
Let's address this in a follow-up PR
Yup, seems something caused by our sandboxes, I can see it as long as I'm sandboxed (even when D50134-code is not applied), so definitely unrelated to these changes. |
Deployed to WP.com in r214381-wpcom. |
@mmtr does it make sense to serialize so much markup as a fallback? I was thinking it would only include the button, which is where this block should be heading. |
@mtias I think that ideally a block should aim for a markup that works anywhere, so we don't need to augment it. If that is not doable, then the more markup is shared between the fallback and the augmented UI, the easier is going to be the code maintenance. I agree that it'd be great if this block would be only a button, so users can use other blocks (paragraphs, headings, images) for describing the product they are selling. But in the meantime, I think it's important that the fallback offers enough context to visitors so they can understand the purpose of the block. Imagine that the fallback of this block would be only a link (it cannot be a button because it does not work on emails) that redirects visitors to the full post in the frontend so they can complete the purchase. These visitors will lack some info such as "what product is the site selling?" or "how much does is cost?". |
Fixes #17246
Fixes #17161
Fixes #15591
Changes proposed in this Pull Request:
As @mtias noted in paYKcK-FI-p2#comment-831, the
save
function of a block is conceptually the proper fallback whilerender_callback
is instead intended for augmenting the content dynamically.In other words, the
save
function should return an output that works well enough in any context (email, notifications, feed, as well as unknown clients getting post content from an API, etc). Then, for cases where we want to provide a richer UI (such in the site frontend), therender_callback
function should be used for manipulating the block content.This PR modifies the Pay with PayPal block implementation so it follows the approach above:
[simple-payment]
shortcode.jetpack_is_frontend
function).Jetpack product discussion
paYKcK-FI-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Web
master
.update/pay-with-paypal-save-fallback
).API
GET
request to/sites/:site/posts/:post-id
(where:post-id
is the ID of a post that contains a Pay with PayPal block).Email, notifications, and reader (only testable in WP.com)
php ./bin/subscriptions/send.php <BLOG_ID> post <POST_ID> <YOUR_EMAIL>
.Proposed changelog entry for your changes:
Pay with PayPal block: Save fallback into post content